OSDN Git Service

2003-11-10 Ed Falis <falis@gnat.com>
[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-2003, 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_Generated_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    --  Ouput 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_Expanded_Name =>
1236             Sprint_Node (Prefix (Node));
1237             Write_Char_Sloc ('.');
1238             Sprint_Node (Selector_Name (Node));
1239
1240          when N_Explicit_Dereference =>
1241             Sprint_Node (Prefix (Node));
1242             Write_Char_Sloc ('.');
1243             Write_Str_Sloc ("all");
1244
1245          when N_Extension_Aggregate =>
1246             Write_Str_With_Col_Check_Sloc ("(");
1247             Sprint_Node (Ancestor_Part (Node));
1248             Write_Str_With_Col_Check (" with ");
1249
1250             if Null_Record_Present (Node) then
1251                Write_Str_With_Col_Check ("null record");
1252             else
1253                if Present (Expressions (Node)) then
1254                   Sprint_Comma_List (Expressions (Node));
1255
1256                   if Present (Component_Associations (Node)) then
1257                      Write_Str (", ");
1258                   end if;
1259                end if;
1260
1261                if Present (Component_Associations (Node)) then
1262                   Sprint_Comma_List (Component_Associations (Node));
1263                end if;
1264             end if;
1265
1266             Write_Char (')');
1267
1268          when N_Floating_Point_Definition =>
1269             Write_Str_With_Col_Check_Sloc ("digits ");
1270             Sprint_Node (Digits_Expression (Node));
1271             Sprint_Opt_Node (Real_Range_Specification (Node));
1272
1273          when N_Formal_Decimal_Fixed_Point_Definition =>
1274             Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1275
1276          when N_Formal_Derived_Type_Definition =>
1277             Write_Str_With_Col_Check_Sloc ("new ");
1278             Sprint_Node (Subtype_Mark (Node));
1279
1280             if Private_Present (Node) then
1281                Write_Str_With_Col_Check (" with private");
1282             end if;
1283
1284          when N_Formal_Discrete_Type_Definition =>
1285             Write_Str_With_Col_Check_Sloc ("<>");
1286
1287          when N_Formal_Floating_Point_Definition =>
1288             Write_Str_With_Col_Check_Sloc ("digits <>");
1289
1290          when N_Formal_Modular_Type_Definition =>
1291             Write_Str_With_Col_Check_Sloc ("mod <>");
1292
1293          when N_Formal_Object_Declaration =>
1294             Set_Debug_Sloc;
1295
1296             if Write_Indent_Identifiers (Node) then
1297                Write_Str (" : ");
1298
1299                if In_Present (Node) then
1300                   Write_Str_With_Col_Check ("in ");
1301                end if;
1302
1303                if Out_Present (Node) then
1304                   Write_Str_With_Col_Check ("out ");
1305                end if;
1306
1307                Sprint_Node (Subtype_Mark (Node));
1308
1309                if Present (Expression (Node)) then
1310                   Write_Str (" := ");
1311                   Sprint_Node (Expression (Node));
1312                end if;
1313
1314                Write_Char (';');
1315             end if;
1316
1317          when N_Formal_Ordinary_Fixed_Point_Definition =>
1318             Write_Str_With_Col_Check_Sloc ("delta <>");
1319
1320          when N_Formal_Package_Declaration =>
1321             Write_Indent_Str_Sloc ("with package ");
1322             Write_Id (Defining_Identifier (Node));
1323             Write_Str_With_Col_Check (" is new ");
1324             Sprint_Node (Name (Node));
1325             Write_Str_With_Col_Check (" (<>);");
1326
1327          when N_Formal_Private_Type_Definition =>
1328             if Abstract_Present (Node) then
1329                Write_Str_With_Col_Check ("abstract ");
1330             end if;
1331
1332             if Tagged_Present (Node) then
1333                Write_Str_With_Col_Check ("tagged ");
1334             end if;
1335
1336             if Limited_Present (Node) then
1337                Write_Str_With_Col_Check ("limited ");
1338             end if;
1339
1340             Write_Str_With_Col_Check_Sloc ("private");
1341
1342          when N_Formal_Signed_Integer_Type_Definition =>
1343             Write_Str_With_Col_Check_Sloc ("range <>");
1344
1345          when N_Formal_Subprogram_Declaration =>
1346             Write_Indent_Str_Sloc ("with ");
1347             Sprint_Node (Specification (Node));
1348
1349             if Box_Present (Node) then
1350                Write_Str_With_Col_Check (" is <>");
1351             elsif Present (Default_Name (Node)) then
1352                Write_Str_With_Col_Check (" is ");
1353                Sprint_Node (Default_Name (Node));
1354             end if;
1355
1356             Write_Char (';');
1357
1358          when N_Formal_Type_Declaration =>
1359             Write_Indent_Str_Sloc ("type ");
1360             Write_Id (Defining_Identifier (Node));
1361
1362             if Present (Discriminant_Specifications (Node)) then
1363                Write_Discr_Specs (Node);
1364             elsif Unknown_Discriminants_Present (Node) then
1365                Write_Str_With_Col_Check ("(<>)");
1366             end if;
1367
1368             Write_Str_With_Col_Check (" is ");
1369             Sprint_Node (Formal_Type_Definition (Node));
1370             Write_Char (';');
1371
1372          when N_Free_Statement =>
1373             Write_Indent_Str_Sloc ("free ");
1374             Sprint_Node (Expression (Node));
1375             Write_Char (';');
1376
1377          when N_Freeze_Entity =>
1378             if Dump_Original_Only then
1379                null;
1380
1381             elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1382                Write_Indent;
1383                Write_Rewrite_Str ("<<<");
1384                Write_Str_With_Col_Check_Sloc ("freeze ");
1385                Write_Id (Entity (Node));
1386                Write_Str (" [");
1387
1388                if No (Actions (Node)) then
1389                   Write_Char (']');
1390
1391                else
1392                   Freeze_Indent := Freeze_Indent + 1;
1393                   Sprint_Indented_List (Actions (Node));
1394                   Freeze_Indent := Freeze_Indent - 1;
1395                   Write_Indent_Str ("]");
1396                end if;
1397
1398                Write_Rewrite_Str (">>>");
1399             end if;
1400
1401          when N_Full_Type_Declaration =>
1402             Write_Indent_Str_Sloc ("type ");
1403             Write_Id (Defining_Identifier (Node));
1404             Write_Discr_Specs (Node);
1405             Write_Str_With_Col_Check (" is ");
1406             Sprint_Node (Type_Definition (Node));
1407             Write_Char (';');
1408
1409          when N_Function_Call =>
1410             Set_Debug_Sloc;
1411             Sprint_Node (Name (Node));
1412             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1413
1414          when N_Function_Instantiation =>
1415             Write_Indent_Str_Sloc ("function ");
1416             Sprint_Node (Defining_Unit_Name (Node));
1417             Write_Str_With_Col_Check (" is new ");
1418             Sprint_Node (Name (Node));
1419             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1420             Write_Char (';');
1421
1422          when N_Function_Specification =>
1423             Write_Str_With_Col_Check_Sloc ("function ");
1424             Sprint_Node (Defining_Unit_Name (Node));
1425             Write_Param_Specs (Node);
1426             Write_Str_With_Col_Check (" return ");
1427             Sprint_Node (Subtype_Mark (Node));
1428
1429          when N_Generic_Association =>
1430             Set_Debug_Sloc;
1431
1432             if Present (Selector_Name (Node)) then
1433                Sprint_Node (Selector_Name (Node));
1434                Write_Str (" => ");
1435             end if;
1436
1437             Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1438
1439          when N_Generic_Function_Renaming_Declaration =>
1440             Write_Indent_Str_Sloc ("generic function ");
1441             Sprint_Node (Defining_Unit_Name (Node));
1442             Write_Str_With_Col_Check (" renames ");
1443             Sprint_Node (Name (Node));
1444             Write_Char (';');
1445
1446          when N_Generic_Package_Declaration =>
1447             Write_Indent;
1448             Write_Indent_Str_Sloc ("generic ");
1449             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1450             Write_Indent;
1451             Sprint_Node (Specification (Node));
1452             Write_Char (';');
1453
1454          when N_Generic_Package_Renaming_Declaration =>
1455             Write_Indent_Str_Sloc ("generic package ");
1456             Sprint_Node (Defining_Unit_Name (Node));
1457             Write_Str_With_Col_Check (" renames ");
1458             Sprint_Node (Name (Node));
1459             Write_Char (';');
1460
1461          when N_Generic_Procedure_Renaming_Declaration =>
1462             Write_Indent_Str_Sloc ("generic procedure ");
1463             Sprint_Node (Defining_Unit_Name (Node));
1464             Write_Str_With_Col_Check (" renames ");
1465             Sprint_Node (Name (Node));
1466             Write_Char (';');
1467
1468          when N_Generic_Subprogram_Declaration =>
1469             Write_Indent;
1470             Write_Indent_Str_Sloc ("generic ");
1471             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1472             Write_Indent;
1473             Sprint_Node (Specification (Node));
1474             Write_Char (';');
1475
1476          when N_Goto_Statement =>
1477             Write_Indent_Str_Sloc ("goto ");
1478             Sprint_Node (Name (Node));
1479             Write_Char (';');
1480
1481             if Nkind (Next (Node)) = N_Label then
1482                Write_Indent;
1483             end if;
1484
1485          when N_Handled_Sequence_Of_Statements =>
1486             Set_Debug_Sloc;
1487             Sprint_Indented_List (Statements (Node));
1488
1489             if Present (Exception_Handlers (Node)) then
1490                Write_Indent_Str ("exception");
1491                Indent_Begin;
1492                Sprint_Node_List (Exception_Handlers (Node));
1493                Indent_End;
1494             end if;
1495
1496             if Present (At_End_Proc (Node)) then
1497                Write_Indent_Str ("at end");
1498                Indent_Begin;
1499                Write_Indent;
1500                Sprint_Node (At_End_Proc (Node));
1501                Write_Char (';');
1502                Indent_End;
1503             end if;
1504
1505          when N_Identifier =>
1506             Set_Debug_Sloc;
1507             Write_Id (Node);
1508
1509          when N_If_Statement =>
1510             Write_Indent_Str_Sloc ("if ");
1511             Sprint_Node (Condition (Node));
1512             Write_Str_With_Col_Check (" then");
1513             Sprint_Indented_List (Then_Statements (Node));
1514             Sprint_Opt_Node_List (Elsif_Parts (Node));
1515
1516             if Present (Else_Statements (Node)) then
1517                Write_Indent_Str ("else");
1518                Sprint_Indented_List (Else_Statements (Node));
1519             end if;
1520
1521             Write_Indent_Str ("end if;");
1522
1523          when N_Implicit_Label_Declaration =>
1524             if not Dump_Original_Only then
1525                Write_Indent;
1526                Write_Rewrite_Str ("<<<");
1527                Set_Debug_Sloc;
1528                Write_Id (Defining_Identifier (Node));
1529                Write_Str (" : ");
1530                Write_Str_With_Col_Check ("label");
1531                Write_Rewrite_Str (">>>");
1532             end if;
1533
1534          when N_In =>
1535             Sprint_Left_Opnd (Node);
1536             Write_Str_Sloc (" in ");
1537             Sprint_Right_Opnd (Node);
1538
1539          when N_Incomplete_Type_Declaration =>
1540             Write_Indent_Str_Sloc ("type ");
1541             Write_Id (Defining_Identifier (Node));
1542
1543             if Present (Discriminant_Specifications (Node)) then
1544                Write_Discr_Specs (Node);
1545             elsif Unknown_Discriminants_Present (Node) then
1546                Write_Str_With_Col_Check ("(<>)");
1547             end if;
1548
1549             Write_Char (';');
1550
1551          when N_Index_Or_Discriminant_Constraint =>
1552             Set_Debug_Sloc;
1553             Sprint_Paren_Comma_List (Constraints (Node));
1554
1555          when N_Indexed_Component =>
1556             Sprint_Node_Sloc (Prefix (Node));
1557             Sprint_Opt_Paren_Comma_List (Expressions (Node));
1558
1559          when N_Integer_Literal =>
1560             if Print_In_Hex (Node) then
1561                Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1562             else
1563                Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1564             end if;
1565
1566          when N_Iteration_Scheme =>
1567             if Present (Condition (Node)) then
1568                Write_Str_With_Col_Check_Sloc ("while ");
1569                Sprint_Node (Condition (Node));
1570             else
1571                Write_Str_With_Col_Check_Sloc ("for ");
1572                Sprint_Node (Loop_Parameter_Specification (Node));
1573             end if;
1574
1575             Write_Char (' ');
1576
1577          when N_Itype_Reference =>
1578             Write_Indent_Str_Sloc ("reference ");
1579             Write_Id (Itype (Node));
1580
1581          when N_Label =>
1582             Write_Indent_Str_Sloc ("<<");
1583             Write_Id (Identifier (Node));
1584             Write_Str (">>");
1585
1586          when N_Loop_Parameter_Specification =>
1587             Set_Debug_Sloc;
1588             Write_Id (Defining_Identifier (Node));
1589             Write_Str_With_Col_Check (" in ");
1590
1591             if Reverse_Present (Node) then
1592                Write_Str_With_Col_Check ("reverse ");
1593             end if;
1594
1595             Sprint_Node (Discrete_Subtype_Definition (Node));
1596
1597          when N_Loop_Statement =>
1598             Write_Indent;
1599
1600             if Present (Identifier (Node))
1601               and then (not Has_Created_Identifier (Node)
1602                           or else not Dump_Original_Only)
1603             then
1604                Write_Rewrite_Str ("<<<");
1605                Write_Id (Identifier (Node));
1606                Write_Str (" : ");
1607                Write_Rewrite_Str (">>>");
1608                Sprint_Node (Iteration_Scheme (Node));
1609                Write_Str_With_Col_Check_Sloc ("loop");
1610                Sprint_Indented_List (Statements (Node));
1611                Write_Indent_Str ("end loop ");
1612                Write_Rewrite_Str ("<<<");
1613                Write_Id (Identifier (Node));
1614                Write_Rewrite_Str (">>>");
1615                Write_Char (';');
1616
1617             else
1618                Sprint_Node (Iteration_Scheme (Node));
1619                Write_Str_With_Col_Check_Sloc ("loop");
1620                Sprint_Indented_List (Statements (Node));
1621                Write_Indent_Str ("end loop;");
1622             end if;
1623
1624          when N_Mod_Clause =>
1625             Sprint_Node_List (Pragmas_Before (Node));
1626             Write_Str_With_Col_Check_Sloc ("at mod ");
1627             Sprint_Node (Expression (Node));
1628
1629          when N_Modular_Type_Definition =>
1630             Write_Str_With_Col_Check_Sloc ("mod ");
1631             Sprint_Node (Expression (Node));
1632
1633          when N_Not_In =>
1634             Sprint_Left_Opnd (Node);
1635             Write_Str_Sloc (" not in ");
1636             Sprint_Right_Opnd (Node);
1637
1638          when N_Null =>
1639             Write_Str_With_Col_Check_Sloc ("null");
1640
1641          when N_Null_Statement =>
1642             if Comes_From_Source (Node)
1643               or else Dump_Freeze_Null
1644               or else not Is_List_Member (Node)
1645               or else (No (Prev (Node)) and then No (Next (Node)))
1646             then
1647                Write_Indent_Str_Sloc ("null;");
1648             end if;
1649
1650          when N_Number_Declaration =>
1651             Set_Debug_Sloc;
1652
1653             if Write_Indent_Identifiers (Node) then
1654                Write_Str_With_Col_Check (" : constant ");
1655                Write_Str (" := ");
1656                Sprint_Node (Expression (Node));
1657                Write_Char (';');
1658             end if;
1659
1660          when N_Object_Declaration =>
1661             Set_Debug_Sloc;
1662
1663             if Write_Indent_Identifiers (Node) then
1664                Write_Str (" : ");
1665
1666                if Aliased_Present (Node) then
1667                   Write_Str_With_Col_Check ("aliased ");
1668                end if;
1669
1670                if Constant_Present (Node) then
1671                   Write_Str_With_Col_Check ("constant ");
1672                end if;
1673
1674                Sprint_Node (Object_Definition (Node));
1675
1676                if Present (Expression (Node)) then
1677                   Write_Str (" := ");
1678                   Sprint_Node (Expression (Node));
1679                end if;
1680
1681                Write_Char (';');
1682             end if;
1683
1684          when N_Object_Renaming_Declaration =>
1685             Write_Indent;
1686             Set_Debug_Sloc;
1687             Sprint_Node (Defining_Identifier (Node));
1688             Write_Str (" : ");
1689             Sprint_Node (Subtype_Mark (Node));
1690             Write_Str_With_Col_Check (" renames ");
1691             Sprint_Node (Name (Node));
1692             Write_Char (';');
1693
1694          when N_Op_Abs =>
1695             Write_Operator (Node, "abs ");
1696             Sprint_Right_Opnd (Node);
1697
1698          when N_Op_Add =>
1699             Sprint_Left_Opnd (Node);
1700             Write_Operator (Node, " + ");
1701             Sprint_Right_Opnd (Node);
1702
1703          when N_Op_And =>
1704             Sprint_Left_Opnd (Node);
1705             Write_Operator (Node, " and ");
1706             Sprint_Right_Opnd (Node);
1707
1708          when N_Op_Concat =>
1709             Sprint_Left_Opnd (Node);
1710             Write_Operator (Node, " & ");
1711             Sprint_Right_Opnd (Node);
1712
1713          when N_Op_Divide =>
1714             Sprint_Left_Opnd (Node);
1715             Write_Char (' ');
1716             Process_TFAI_RR_Flags (Node);
1717             Write_Operator (Node, "/ ");
1718             Sprint_Right_Opnd (Node);
1719
1720          when N_Op_Eq =>
1721             Sprint_Left_Opnd (Node);
1722             Write_Operator (Node, " = ");
1723             Sprint_Right_Opnd (Node);
1724
1725          when N_Op_Expon =>
1726             Sprint_Left_Opnd (Node);
1727             Write_Operator (Node, " ** ");
1728             Sprint_Right_Opnd (Node);
1729
1730          when N_Op_Ge =>
1731             Sprint_Left_Opnd (Node);
1732             Write_Operator (Node, " >= ");
1733             Sprint_Right_Opnd (Node);
1734
1735          when N_Op_Gt =>
1736             Sprint_Left_Opnd (Node);
1737             Write_Operator (Node, " > ");
1738             Sprint_Right_Opnd (Node);
1739
1740          when N_Op_Le =>
1741             Sprint_Left_Opnd (Node);
1742             Write_Operator (Node, " <= ");
1743             Sprint_Right_Opnd (Node);
1744
1745          when N_Op_Lt =>
1746             Sprint_Left_Opnd (Node);
1747             Write_Operator (Node, " < ");
1748             Sprint_Right_Opnd (Node);
1749
1750          when N_Op_Minus =>
1751             Write_Operator (Node, "-");
1752             Sprint_Right_Opnd (Node);
1753
1754          when N_Op_Mod =>
1755             Sprint_Left_Opnd (Node);
1756
1757             if Treat_Fixed_As_Integer (Node) then
1758                Write_Str (" #");
1759             end if;
1760
1761             Write_Operator (Node, " mod ");
1762             Sprint_Right_Opnd (Node);
1763
1764          when N_Op_Multiply =>
1765             Sprint_Left_Opnd (Node);
1766             Write_Char (' ');
1767             Process_TFAI_RR_Flags (Node);
1768             Write_Operator (Node, "* ");
1769             Sprint_Right_Opnd (Node);
1770
1771          when N_Op_Ne =>
1772             Sprint_Left_Opnd (Node);
1773             Write_Operator (Node, " /= ");
1774             Sprint_Right_Opnd (Node);
1775
1776          when N_Op_Not =>
1777             Write_Operator (Node, "not ");
1778             Sprint_Right_Opnd (Node);
1779
1780          when N_Op_Or =>
1781             Sprint_Left_Opnd (Node);
1782             Write_Operator (Node, " or ");
1783             Sprint_Right_Opnd (Node);
1784
1785          when N_Op_Plus =>
1786             Write_Operator (Node, "+");
1787             Sprint_Right_Opnd (Node);
1788
1789          when N_Op_Rem =>
1790             Sprint_Left_Opnd (Node);
1791
1792             if Treat_Fixed_As_Integer (Node) then
1793                Write_Str (" #");
1794             end if;
1795
1796             Write_Operator (Node, " rem ");
1797             Sprint_Right_Opnd (Node);
1798
1799          when N_Op_Shift =>
1800             Set_Debug_Sloc;
1801             Write_Id (Node);
1802             Write_Char ('!');
1803             Write_Str_With_Col_Check ("(");
1804             Sprint_Node (Left_Opnd (Node));
1805             Write_Str (", ");
1806             Sprint_Node (Right_Opnd (Node));
1807             Write_Char (')');
1808
1809          when N_Op_Subtract =>
1810             Sprint_Left_Opnd (Node);
1811             Write_Operator (Node, " - ");
1812             Sprint_Right_Opnd (Node);
1813
1814          when N_Op_Xor =>
1815             Sprint_Left_Opnd (Node);
1816             Write_Operator (Node, " xor ");
1817             Sprint_Right_Opnd (Node);
1818
1819          when N_Operator_Symbol =>
1820             Write_Name_With_Col_Check_Sloc (Chars (Node));
1821
1822          when N_Ordinary_Fixed_Point_Definition =>
1823             Write_Str_With_Col_Check_Sloc ("delta ");
1824             Sprint_Node (Delta_Expression (Node));
1825             Sprint_Opt_Node (Real_Range_Specification (Node));
1826
1827          when N_Or_Else =>
1828             Sprint_Left_Opnd (Node);
1829             Write_Str_Sloc (" or else ");
1830             Sprint_Right_Opnd (Node);
1831
1832          when N_Others_Choice =>
1833             if All_Others (Node) then
1834                Write_Str_With_Col_Check ("all ");
1835             end if;
1836
1837             Write_Str_With_Col_Check_Sloc ("others");
1838
1839          when N_Package_Body =>
1840             Write_Indent;
1841             Write_Indent_Str_Sloc ("package body ");
1842             Sprint_Node (Defining_Unit_Name (Node));
1843             Write_Str (" is");
1844             Sprint_Indented_List (Declarations (Node));
1845
1846             if Present (Handled_Statement_Sequence (Node)) then
1847                Write_Indent_Str ("begin");
1848                Sprint_Node (Handled_Statement_Sequence (Node));
1849             end if;
1850
1851             Write_Indent_Str ("end ");
1852             Sprint_Node (Defining_Unit_Name (Node));
1853             Write_Char (';');
1854
1855          when N_Package_Body_Stub =>
1856             Write_Indent_Str_Sloc ("package body ");
1857             Sprint_Node (Defining_Identifier (Node));
1858             Write_Str_With_Col_Check (" is separate;");
1859
1860          when N_Package_Declaration =>
1861             Write_Indent;
1862             Write_Indent;
1863             Sprint_Node_Sloc (Specification (Node));
1864             Write_Char (';');
1865
1866          when N_Package_Instantiation =>
1867             Write_Indent;
1868             Write_Indent_Str_Sloc ("package ");
1869             Sprint_Node (Defining_Unit_Name (Node));
1870             Write_Str (" is new ");
1871             Sprint_Node (Name (Node));
1872             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1873             Write_Char (';');
1874
1875          when N_Package_Renaming_Declaration =>
1876             Write_Indent_Str_Sloc ("package ");
1877             Sprint_Node (Defining_Unit_Name (Node));
1878             Write_Str_With_Col_Check (" renames ");
1879             Sprint_Node (Name (Node));
1880             Write_Char (';');
1881
1882          when N_Package_Specification =>
1883             Write_Str_With_Col_Check_Sloc ("package ");
1884             Sprint_Node (Defining_Unit_Name (Node));
1885             Write_Str (" is");
1886             Sprint_Indented_List (Visible_Declarations (Node));
1887
1888             if Present (Private_Declarations (Node)) then
1889                Write_Indent_Str ("private");
1890                Sprint_Indented_List (Private_Declarations (Node));
1891             end if;
1892
1893             Write_Indent_Str ("end ");
1894             Sprint_Node (Defining_Unit_Name (Node));
1895
1896          when N_Parameter_Association =>
1897             Sprint_Node_Sloc (Selector_Name (Node));
1898             Write_Str (" => ");
1899             Sprint_Node (Explicit_Actual_Parameter (Node));
1900
1901          when N_Parameter_Specification =>
1902             Set_Debug_Sloc;
1903
1904             if Write_Identifiers (Node) then
1905                Write_Str (" : ");
1906
1907                if In_Present (Node) then
1908                   Write_Str_With_Col_Check ("in ");
1909                end if;
1910
1911                if Out_Present (Node) then
1912                   Write_Str_With_Col_Check ("out ");
1913                end if;
1914
1915                Sprint_Node (Parameter_Type (Node));
1916
1917                if Present (Expression (Node)) then
1918                   Write_Str (" := ");
1919                   Sprint_Node (Expression (Node));
1920                end if;
1921             else
1922                Write_Str (", ");
1923             end if;
1924
1925          when N_Pragma =>
1926             Write_Indent_Str_Sloc ("pragma ");
1927             Write_Name_With_Col_Check (Chars (Node));
1928
1929             if Present (Pragma_Argument_Associations (Node)) then
1930                Sprint_Opt_Paren_Comma_List
1931                  (Pragma_Argument_Associations (Node));
1932             end if;
1933
1934             Write_Char (';');
1935
1936          when N_Pragma_Argument_Association =>
1937             Set_Debug_Sloc;
1938
1939             if Chars (Node) /= No_Name then
1940                Write_Name_With_Col_Check (Chars (Node));
1941                Write_Str (" => ");
1942             end if;
1943
1944             Sprint_Node (Expression (Node));
1945
1946          when N_Private_Type_Declaration =>
1947             Write_Indent_Str_Sloc ("type ");
1948             Write_Id (Defining_Identifier (Node));
1949
1950             if Present (Discriminant_Specifications (Node)) then
1951                Write_Discr_Specs (Node);
1952             elsif Unknown_Discriminants_Present (Node) then
1953                Write_Str_With_Col_Check ("(<>)");
1954             end if;
1955
1956             Write_Str (" is ");
1957
1958             if Tagged_Present (Node) then
1959                Write_Str_With_Col_Check ("tagged ");
1960             end if;
1961
1962             if Limited_Present (Node) then
1963                Write_Str_With_Col_Check ("limited ");
1964             end if;
1965
1966             Write_Str_With_Col_Check ("private;");
1967
1968          when N_Private_Extension_Declaration =>
1969             Write_Indent_Str_Sloc ("type ");
1970             Write_Id (Defining_Identifier (Node));
1971
1972             if Present (Discriminant_Specifications (Node)) then
1973                Write_Discr_Specs (Node);
1974             elsif Unknown_Discriminants_Present (Node) then
1975                Write_Str_With_Col_Check ("(<>)");
1976             end if;
1977
1978             Write_Str_With_Col_Check (" is new ");
1979             Sprint_Node (Subtype_Indication (Node));
1980             Write_Str_With_Col_Check (" with private;");
1981
1982          when N_Procedure_Call_Statement =>
1983             Write_Indent;
1984             Set_Debug_Sloc;
1985             Sprint_Node (Name (Node));
1986             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1987             Write_Char (';');
1988
1989          when N_Procedure_Instantiation =>
1990             Write_Indent_Str_Sloc ("procedure ");
1991             Sprint_Node (Defining_Unit_Name (Node));
1992             Write_Str_With_Col_Check (" is new ");
1993             Sprint_Node (Name (Node));
1994             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1995             Write_Char (';');
1996
1997          when N_Procedure_Specification =>
1998             Write_Str_With_Col_Check_Sloc ("procedure ");
1999             Sprint_Node (Defining_Unit_Name (Node));
2000             Write_Param_Specs (Node);
2001
2002          when N_Protected_Body =>
2003             Write_Indent_Str_Sloc ("protected body ");
2004             Write_Id (Defining_Identifier (Node));
2005             Write_Str (" is");
2006             Sprint_Indented_List (Declarations (Node));
2007             Write_Indent_Str ("end ");
2008             Write_Id (Defining_Identifier (Node));
2009             Write_Char (';');
2010
2011          when N_Protected_Body_Stub =>
2012             Write_Indent_Str_Sloc ("protected body ");
2013             Write_Id (Defining_Identifier (Node));
2014             Write_Str_With_Col_Check (" is separate;");
2015
2016          when N_Protected_Definition =>
2017             Set_Debug_Sloc;
2018             Sprint_Indented_List (Visible_Declarations (Node));
2019
2020             if Present (Private_Declarations (Node)) then
2021                Write_Indent_Str ("private");
2022                Sprint_Indented_List (Private_Declarations (Node));
2023             end if;
2024
2025             Write_Indent_Str ("end ");
2026
2027          when N_Protected_Type_Declaration =>
2028             Write_Indent_Str_Sloc ("protected type ");
2029             Write_Id (Defining_Identifier (Node));
2030             Write_Discr_Specs (Node);
2031             Write_Str (" is");
2032             Sprint_Node (Protected_Definition (Node));
2033             Write_Id (Defining_Identifier (Node));
2034             Write_Char (';');
2035
2036          when N_Qualified_Expression =>
2037             Sprint_Node (Subtype_Mark (Node));
2038             Write_Char_Sloc (''');
2039
2040             --  Print expression, make sure we have at least one level of
2041             --  parentheses around the expression. For cases of qualified
2042             --  expressions in the source, this is always the case, but
2043             --  for generated qualifications, there may be no explicit
2044             --  parentheses present.
2045
2046             if Paren_Count (Expression (Node)) /= 0 then
2047                Sprint_Node (Expression (Node));
2048             else
2049                Write_Char ('(');
2050                Sprint_Node (Expression (Node));
2051                Write_Char (')');
2052             end if;
2053
2054          when N_Raise_Constraint_Error =>
2055
2056             --  This node can be used either as a subexpression or as a
2057             --  statement form. The following test is a reasonably reliable
2058             --  way to distinguish the two cases.
2059
2060             if Is_List_Member (Node)
2061               and then Nkind (Parent (Node)) not in N_Subexpr
2062             then
2063                Write_Indent;
2064             end if;
2065
2066             Write_Str_With_Col_Check_Sloc ("[constraint_error");
2067             Write_Condition_And_Reason (Node);
2068
2069          when N_Raise_Program_Error =>
2070
2071             --  This node can be used either as a subexpression or as a
2072             --  statement form. The following test is a reasonably reliable
2073             --  way to distinguish the two cases.
2074
2075             if Is_List_Member (Node)
2076               and then Nkind (Parent (Node)) not in N_Subexpr
2077             then
2078                Write_Indent;
2079             end if;
2080
2081             Write_Str_With_Col_Check_Sloc ("[program_error");
2082             Write_Condition_And_Reason (Node);
2083
2084          when N_Raise_Storage_Error =>
2085
2086             --  This node can be used either as a subexpression or as a
2087             --  statement form. The following test is a reasonably reliable
2088             --  way to distinguish the two cases.
2089
2090             if Is_List_Member (Node)
2091               and then Nkind (Parent (Node)) not in N_Subexpr
2092             then
2093                Write_Indent;
2094             end if;
2095
2096             Write_Str_With_Col_Check_Sloc ("[storage_error");
2097             Write_Condition_And_Reason (Node);
2098
2099          when N_Raise_Statement =>
2100             Write_Indent_Str_Sloc ("raise ");
2101             Sprint_Node (Name (Node));
2102             Write_Char (';');
2103
2104          when N_Range =>
2105             Sprint_Node (Low_Bound (Node));
2106             Write_Str_Sloc (" .. ");
2107             Sprint_Node (High_Bound (Node));
2108
2109          when N_Range_Constraint =>
2110             Write_Str_With_Col_Check_Sloc ("range ");
2111             Sprint_Node (Range_Expression (Node));
2112
2113          when N_Real_Literal =>
2114             Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2115
2116          when N_Real_Range_Specification =>
2117             Write_Str_With_Col_Check_Sloc ("range ");
2118             Sprint_Node (Low_Bound (Node));
2119             Write_Str (" .. ");
2120             Sprint_Node (High_Bound (Node));
2121
2122          when N_Record_Definition =>
2123             if Abstract_Present (Node) then
2124                Write_Str_With_Col_Check ("abstract ");
2125             end if;
2126
2127             if Tagged_Present (Node) then
2128                Write_Str_With_Col_Check ("tagged ");
2129             end if;
2130
2131             if Limited_Present (Node) then
2132                Write_Str_With_Col_Check ("limited ");
2133             end if;
2134
2135             if Null_Present (Node) then
2136                Write_Str_With_Col_Check_Sloc ("null record");
2137
2138             else
2139                Write_Str_With_Col_Check_Sloc ("record");
2140                Sprint_Node (Component_List (Node));
2141                Write_Indent_Str ("end record");
2142             end if;
2143
2144          when N_Record_Representation_Clause =>
2145             Write_Indent_Str_Sloc ("for ");
2146             Sprint_Node (Identifier (Node));
2147             Write_Str_With_Col_Check (" use record ");
2148
2149             if Present (Mod_Clause (Node)) then
2150                Sprint_Node (Mod_Clause (Node));
2151             end if;
2152
2153             Sprint_Indented_List (Component_Clauses (Node));
2154             Write_Indent_Str ("end record;");
2155
2156          when N_Reference =>
2157             Sprint_Node (Prefix (Node));
2158             Write_Str_With_Col_Check_Sloc ("'reference");
2159
2160          when N_Requeue_Statement =>
2161             Write_Indent_Str_Sloc ("requeue ");
2162             Sprint_Node (Name (Node));
2163
2164             if Abort_Present (Node) then
2165                Write_Str_With_Col_Check (" with abort");
2166             end if;
2167
2168             Write_Char (';');
2169
2170          when N_Return_Statement =>
2171             if Present (Expression (Node)) then
2172                Write_Indent_Str_Sloc ("return ");
2173                Sprint_Node (Expression (Node));
2174                Write_Char (';');
2175             else
2176                Write_Indent_Str_Sloc ("return;");
2177             end if;
2178
2179          when N_Selective_Accept =>
2180             Write_Indent_Str_Sloc ("select");
2181
2182             declare
2183                Alt_Node : Node_Id;
2184
2185             begin
2186                Alt_Node := First (Select_Alternatives (Node));
2187                loop
2188                   Indent_Begin;
2189                   Sprint_Node (Alt_Node);
2190                   Indent_End;
2191                   Next (Alt_Node);
2192                   exit when No (Alt_Node);
2193                   Write_Indent_Str ("or");
2194                end loop;
2195             end;
2196
2197             if Present (Else_Statements (Node)) then
2198                Write_Indent_Str ("else");
2199                Sprint_Indented_List (Else_Statements (Node));
2200             end if;
2201
2202             Write_Indent_Str ("end select;");
2203
2204          when N_Signed_Integer_Type_Definition =>
2205             Write_Str_With_Col_Check_Sloc ("range ");
2206             Sprint_Node (Low_Bound (Node));
2207             Write_Str (" .. ");
2208             Sprint_Node (High_Bound (Node));
2209
2210          when N_Single_Protected_Declaration =>
2211             Write_Indent_Str_Sloc ("protected ");
2212             Write_Id (Defining_Identifier (Node));
2213             Write_Str (" is");
2214             Sprint_Node (Protected_Definition (Node));
2215             Write_Id (Defining_Identifier (Node));
2216             Write_Char (';');
2217
2218          when N_Single_Task_Declaration =>
2219             Write_Indent_Str_Sloc ("task ");
2220             Write_Id (Defining_Identifier (Node));
2221
2222             if Present (Task_Definition (Node)) then
2223                Write_Str (" is");
2224                Sprint_Node (Task_Definition (Node));
2225                Write_Id (Defining_Identifier (Node));
2226             end if;
2227
2228             Write_Char (';');
2229
2230          when N_Selected_Component =>
2231             Sprint_Node (Prefix (Node));
2232             Write_Char_Sloc ('.');
2233             Sprint_Node (Selector_Name (Node));
2234
2235          when N_Slice =>
2236             Set_Debug_Sloc;
2237             Sprint_Node (Prefix (Node));
2238             Write_Str_With_Col_Check (" (");
2239             Sprint_Node (Discrete_Range (Node));
2240             Write_Char (')');
2241
2242          when N_String_Literal =>
2243             if String_Length (Strval (Node)) + Column > 75 then
2244                Write_Indent_Str ("  ");
2245             end if;
2246
2247             Set_Debug_Sloc;
2248             Write_String_Table_Entry (Strval (Node));
2249
2250          when N_Subprogram_Body =>
2251             if Freeze_Indent = 0 then
2252                Write_Indent;
2253             end if;
2254
2255             Write_Indent;
2256             Sprint_Node_Sloc (Specification (Node));
2257             Write_Str (" is");
2258
2259             Sprint_Indented_List (Declarations (Node));
2260             Write_Indent_Str ("begin");
2261             Sprint_Node (Handled_Statement_Sequence (Node));
2262
2263             Write_Indent_Str ("end ");
2264             Sprint_Node (Defining_Unit_Name (Specification (Node)));
2265             Write_Char (';');
2266
2267             if Is_List_Member (Node)
2268               and then Present (Next (Node))
2269               and then Nkind (Next (Node)) /= N_Subprogram_Body
2270             then
2271                Write_Indent;
2272             end if;
2273
2274          when N_Subprogram_Body_Stub =>
2275             Write_Indent;
2276             Sprint_Node_Sloc (Specification (Node));
2277             Write_Str_With_Col_Check (" is separate;");
2278
2279          when N_Subprogram_Declaration =>
2280             Write_Indent;
2281             Sprint_Node_Sloc (Specification (Node));
2282             Write_Char (';');
2283
2284          when N_Subprogram_Info =>
2285             Sprint_Node (Identifier (Node));
2286             Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2287
2288          when N_Subprogram_Renaming_Declaration =>
2289             Write_Indent;
2290             Sprint_Node (Specification (Node));
2291             Write_Str_With_Col_Check_Sloc (" renames ");
2292             Sprint_Node (Name (Node));
2293             Write_Char (';');
2294
2295          when N_Subtype_Declaration =>
2296             Write_Indent_Str_Sloc ("subtype ");
2297             Write_Id (Defining_Identifier (Node));
2298             Write_Str (" is ");
2299             Sprint_Node (Subtype_Indication (Node));
2300             Write_Char (';');
2301
2302          when N_Subtype_Indication =>
2303             Sprint_Node_Sloc (Subtype_Mark (Node));
2304             Write_Char (' ');
2305             Sprint_Node (Constraint (Node));
2306
2307          when N_Subunit =>
2308             Write_Indent_Str_Sloc ("separate (");
2309             Sprint_Node (Name (Node));
2310             Write_Char (')');
2311             Write_Eol;
2312             Sprint_Node (Proper_Body (Node));
2313
2314          when N_Task_Body =>
2315             Write_Indent_Str_Sloc ("task body ");
2316             Write_Id (Defining_Identifier (Node));
2317             Write_Str (" is");
2318             Sprint_Indented_List (Declarations (Node));
2319             Write_Indent_Str ("begin");
2320             Sprint_Node (Handled_Statement_Sequence (Node));
2321             Write_Indent_Str ("end ");
2322             Write_Id (Defining_Identifier (Node));
2323             Write_Char (';');
2324
2325          when N_Task_Body_Stub =>
2326             Write_Indent_Str_Sloc ("task body ");
2327             Write_Id (Defining_Identifier (Node));
2328             Write_Str_With_Col_Check (" is separate;");
2329
2330          when N_Task_Definition =>
2331             Set_Debug_Sloc;
2332             Sprint_Indented_List (Visible_Declarations (Node));
2333
2334             if Present (Private_Declarations (Node)) then
2335                Write_Indent_Str ("private");
2336                Sprint_Indented_List (Private_Declarations (Node));
2337             end if;
2338
2339             Write_Indent_Str ("end ");
2340
2341          when N_Task_Type_Declaration =>
2342             Write_Indent_Str_Sloc ("task type ");
2343             Write_Id (Defining_Identifier (Node));
2344             Write_Discr_Specs (Node);
2345             if Present (Task_Definition (Node)) then
2346                Write_Str (" is");
2347                Sprint_Node (Task_Definition (Node));
2348                Write_Id (Defining_Identifier (Node));
2349             end if;
2350
2351             Write_Char (';');
2352
2353          when N_Terminate_Alternative =>
2354             Sprint_Node_List (Pragmas_Before (Node));
2355
2356             Write_Indent;
2357
2358             if Present (Condition (Node)) then
2359                Write_Str_With_Col_Check ("when ");
2360                Sprint_Node (Condition (Node));
2361                Write_Str (" => ");
2362             end if;
2363
2364             Write_Str_With_Col_Check_Sloc ("terminate;");
2365             Sprint_Node_List (Pragmas_After (Node));
2366
2367          when N_Timed_Entry_Call =>
2368             Write_Indent_Str_Sloc ("select");
2369             Indent_Begin;
2370             Sprint_Node (Entry_Call_Alternative (Node));
2371             Indent_End;
2372             Write_Indent_Str ("or");
2373             Indent_Begin;
2374             Sprint_Node (Delay_Alternative (Node));
2375             Indent_End;
2376             Write_Indent_Str ("end select;");
2377
2378          when N_Triggering_Alternative =>
2379             Sprint_Node_List (Pragmas_Before (Node));
2380             Sprint_Node_Sloc (Triggering_Statement (Node));
2381             Sprint_Node_List (Statements (Node));
2382
2383          when N_Type_Conversion =>
2384             Set_Debug_Sloc;
2385             Sprint_Node (Subtype_Mark (Node));
2386             Col_Check (4);
2387
2388             if Conversion_OK (Node) then
2389                Write_Char ('?');
2390             end if;
2391
2392             if Float_Truncate (Node) then
2393                Write_Char ('^');
2394             end if;
2395
2396             if Rounded_Result (Node) then
2397                Write_Char ('@');
2398             end if;
2399
2400             Write_Char ('(');
2401             Sprint_Node (Expression (Node));
2402             Write_Char (')');
2403
2404          when N_Unchecked_Expression =>
2405             Col_Check (10);
2406             Write_Str ("`(");
2407             Sprint_Node_Sloc (Expression (Node));
2408             Write_Char (')');
2409
2410          when N_Unchecked_Type_Conversion =>
2411             Sprint_Node (Subtype_Mark (Node));
2412             Write_Char ('!');
2413             Write_Str_With_Col_Check ("(");
2414             Sprint_Node_Sloc (Expression (Node));
2415             Write_Char (')');
2416
2417          when N_Unconstrained_Array_Definition =>
2418             Write_Str_With_Col_Check_Sloc ("array (");
2419
2420             declare
2421                Node1 : Node_Id;
2422
2423             begin
2424                Node1 := First (Subtype_Marks (Node));
2425                loop
2426                   Sprint_Node (Node1);
2427                   Write_Str_With_Col_Check (" range <>");
2428                   Next (Node1);
2429                   exit when Node1 = Empty;
2430                   Write_Str (", ");
2431                end loop;
2432             end;
2433
2434             Write_Str (") of ");
2435
2436             if Aliased_Present (Node) then
2437                Write_Str_With_Col_Check ("aliased ");
2438             end if;
2439
2440             Sprint_Node (Subtype_Indication (Node));
2441
2442          when N_Unused_At_Start | N_Unused_At_End =>
2443             Write_Indent_Str ("***** Error, unused node encountered *****");
2444             Write_Eol;
2445
2446          when N_Use_Package_Clause =>
2447             Write_Indent_Str_Sloc ("use ");
2448             Sprint_Comma_List (Names (Node));
2449             Write_Char (';');
2450
2451          when N_Use_Type_Clause =>
2452             Write_Indent_Str_Sloc ("use type ");
2453             Sprint_Comma_List (Subtype_Marks (Node));
2454             Write_Char (';');
2455
2456          when N_Validate_Unchecked_Conversion =>
2457             Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2458             Sprint_Node (Source_Type (Node));
2459             Write_Str (", ");
2460             Sprint_Node (Target_Type (Node));
2461             Write_Str (");");
2462
2463          when N_Variant =>
2464             Write_Indent_Str_Sloc ("when ");
2465             Sprint_Bar_List (Discrete_Choices (Node));
2466             Write_Str (" => ");
2467             Sprint_Node (Component_List (Node));
2468
2469          when N_Variant_Part =>
2470             Indent_Begin;
2471             Write_Indent_Str_Sloc ("case ");
2472             Sprint_Node (Name (Node));
2473             Write_Str (" is ");
2474             Sprint_Indented_List (Variants (Node));
2475             Write_Indent_Str ("end case");
2476             Indent_End;
2477
2478          when N_With_Clause =>
2479
2480             --  Special test, if we are dumping the original tree only,
2481             --  then we want to eliminate the bogus with clauses that
2482             --  correspond to the non-existent children of Text_IO.
2483
2484             if Dump_Original_Only
2485               and then Is_Text_IO_Kludge_Unit (Name (Node))
2486             then
2487                null;
2488
2489             --  Normal case, output the with clause
2490
2491             else
2492                if First_Name (Node) or else not Dump_Original_Only then
2493                   if Limited_Present (Node) then
2494                      Write_Indent_Str ("limited with ");
2495                   else
2496                      Write_Indent_Str ("with ");
2497                   end if;
2498
2499                else
2500                   Write_Str (", ");
2501                end if;
2502
2503                Sprint_Node_Sloc (Name (Node));
2504
2505                if Last_Name (Node) or else not Dump_Original_Only then
2506                   Write_Char (';');
2507                end if;
2508             end if;
2509
2510          when N_With_Type_Clause =>
2511
2512             Write_Indent_Str ("with type ");
2513             Sprint_Node_Sloc (Name (Node));
2514
2515             if Tagged_Present (Node) then
2516                Write_Str (" is tagged;");
2517             else
2518                Write_Str (" is access;");
2519             end if;
2520
2521       end case;
2522
2523       if Nkind (Node) in N_Subexpr
2524         and then Do_Range_Check (Node)
2525       then
2526          Write_Str ("}");
2527       end if;
2528
2529       for J in 1 .. Paren_Count (Node) loop
2530          Write_Char (')');
2531       end loop;
2532
2533       pragma Assert (No (Debug_Node));
2534       Debug_Node := Save_Debug_Node;
2535    end Sprint_Node_Actual;
2536
2537    ----------------------
2538    -- Sprint_Node_List --
2539    ----------------------
2540
2541    procedure Sprint_Node_List (List : List_Id) is
2542       Node : Node_Id;
2543
2544    begin
2545       if Is_Non_Empty_List (List) then
2546          Node := First (List);
2547
2548          loop
2549             Sprint_Node (Node);
2550             Next (Node);
2551             exit when Node = Empty;
2552          end loop;
2553       end if;
2554    end Sprint_Node_List;
2555
2556    ----------------------
2557    -- Sprint_Node_Sloc --
2558    ----------------------
2559
2560    procedure Sprint_Node_Sloc (Node : Node_Id) is
2561    begin
2562       Sprint_Node (Node);
2563
2564       if Present (Debug_Node) then
2565          Set_Sloc (Debug_Node, Sloc (Node));
2566          Debug_Node := Empty;
2567       end if;
2568    end Sprint_Node_Sloc;
2569
2570    ---------------------
2571    -- Sprint_Opt_Node --
2572    ---------------------
2573
2574    procedure Sprint_Opt_Node (Node : Node_Id) is
2575    begin
2576       if Present (Node) then
2577          Write_Char (' ');
2578          Sprint_Node (Node);
2579       end if;
2580    end Sprint_Opt_Node;
2581
2582    --------------------------
2583    -- Sprint_Opt_Node_List --
2584    --------------------------
2585
2586    procedure Sprint_Opt_Node_List (List : List_Id) is
2587    begin
2588       if Present (List) then
2589          Sprint_Node_List (List);
2590       end if;
2591    end Sprint_Opt_Node_List;
2592
2593    ---------------------------------
2594    -- Sprint_Opt_Paren_Comma_List --
2595    ---------------------------------
2596
2597    procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2598    begin
2599       if Is_Non_Empty_List (List) then
2600          Write_Char (' ');
2601          Sprint_Paren_Comma_List (List);
2602       end if;
2603    end Sprint_Opt_Paren_Comma_List;
2604
2605    -----------------------------
2606    -- Sprint_Paren_Comma_List --
2607    -----------------------------
2608
2609    procedure Sprint_Paren_Comma_List (List : List_Id) is
2610       N           : Node_Id;
2611       Node_Exists : Boolean := False;
2612
2613    begin
2614
2615       if Is_Non_Empty_List (List) then
2616
2617          if Dump_Original_Only then
2618             N := First (List);
2619
2620             while Present (N) loop
2621
2622                if not Is_Rewrite_Insertion (N) then
2623                   Node_Exists := True;
2624                   exit;
2625                end if;
2626
2627                Next (N);
2628             end loop;
2629
2630             if not Node_Exists then
2631                return;
2632             end if;
2633          end if;
2634
2635          Write_Str_With_Col_Check ("(");
2636          Sprint_Comma_List (List);
2637          Write_Char (')');
2638       end if;
2639    end Sprint_Paren_Comma_List;
2640
2641    ----------------------
2642    -- Sprint_Right_Opnd --
2643    ----------------------
2644
2645    procedure Sprint_Right_Opnd (N : Node_Id) is
2646       Opnd : constant Node_Id := Right_Opnd (N);
2647
2648    begin
2649       if Paren_Count (Opnd) /= 0
2650         or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2651       then
2652          Sprint_Node (Opnd);
2653
2654       else
2655          Write_Char ('(');
2656          Sprint_Node (Opnd);
2657          Write_Char (')');
2658       end if;
2659    end Sprint_Right_Opnd;
2660
2661    ---------------------
2662    -- Write_Char_Sloc --
2663    ---------------------
2664
2665    procedure Write_Char_Sloc (C : Character) is
2666    begin
2667       if Debug_Generated_Code and then C /= ' ' then
2668          Set_Debug_Sloc;
2669       end if;
2670
2671       Write_Char (C);
2672    end Write_Char_Sloc;
2673
2674    --------------------------------
2675    -- Write_Condition_And_Reason --
2676    --------------------------------
2677
2678    procedure Write_Condition_And_Reason (Node : Node_Id) is
2679       Image : constant String := RT_Exception_Code'Image
2680                                    (RT_Exception_Code'Val
2681                                      (UI_To_Int (Reason (Node))));
2682
2683    begin
2684       if Present (Condition (Node)) then
2685          Write_Str_With_Col_Check (" when ");
2686          Sprint_Node (Condition (Node));
2687       end if;
2688
2689       Write_Str (" """);
2690
2691       for J in 4 .. Image'Last loop
2692          if Image (J) = '_' then
2693             Write_Char (' ');
2694          else
2695             Write_Char (Fold_Lower (Image (J)));
2696          end if;
2697       end loop;
2698
2699       Write_Str ("""]");
2700    end Write_Condition_And_Reason;
2701
2702    ------------------------
2703    --  Write_Discr_Specs --
2704    ------------------------
2705
2706    procedure Write_Discr_Specs (N : Node_Id) is
2707       Specs  : List_Id;
2708       Spec   : Node_Id;
2709
2710    begin
2711       Specs := Discriminant_Specifications (N);
2712
2713       if Present (Specs) then
2714          Write_Str_With_Col_Check (" (");
2715          Spec := First (Specs);
2716
2717          loop
2718             Sprint_Node (Spec);
2719             Next (Spec);
2720             exit when Spec = Empty;
2721
2722             --  Add semicolon, unless we are printing original tree and the
2723             --  next specification is part of a list (but not the first
2724             --  element of that list)
2725
2726             if not Dump_Original_Only or else not Prev_Ids (Spec) then
2727                Write_Str ("; ");
2728             end if;
2729          end loop;
2730
2731          Write_Char (')');
2732       end if;
2733    end Write_Discr_Specs;
2734
2735    -----------------
2736    -- Write_Ekind --
2737    -----------------
2738
2739    procedure Write_Ekind (E : Entity_Id) is
2740       S : constant String := Entity_Kind'Image (Ekind (E));
2741
2742    begin
2743       Name_Len := S'Length;
2744       Name_Buffer (1 .. Name_Len) := S;
2745       Set_Casing (Mixed_Case);
2746       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2747    end Write_Ekind;
2748
2749    --------------
2750    -- Write_Id --
2751    --------------
2752
2753    procedure Write_Id (N : Node_Id) is
2754    begin
2755       --  Case of a defining identifier
2756
2757       if Nkind (N) = N_Defining_Identifier then
2758
2759          --  If defining identifier has an interface name (and no
2760          --  address clause), then we output the interface name.
2761
2762          if (Is_Imported (N) or else Is_Exported (N))
2763            and then Present (Interface_Name (N))
2764            and then No (Address_Clause (N))
2765          then
2766             String_To_Name_Buffer (Strval (Interface_Name (N)));
2767             Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2768
2769          --  If no interface name (or inactive because there was
2770          --  an address clause), then just output the Chars name.
2771
2772          else
2773             Write_Name_With_Col_Check (Chars (N));
2774          end if;
2775
2776       --  Case of selector of an expanded name where the expanded name
2777       --  has an associated entity, output this entity.
2778
2779       elsif Nkind (Parent (N)) = N_Expanded_Name
2780         and then Selector_Name (Parent (N)) = N
2781         and then Present (Entity (Parent (N)))
2782       then
2783          Write_Id (Entity (Parent (N)));
2784
2785       --  For any other node with an associated entity, output it
2786
2787       elsif Nkind (N) in N_Has_Entity
2788         and then Present (Entity_Or_Associated_Node (N))
2789         and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2790       then
2791          Write_Id (Entity (N));
2792
2793       --  All other cases, we just print the Chars field
2794
2795       else
2796          Write_Name_With_Col_Check (Chars (N));
2797       end if;
2798    end Write_Id;
2799
2800    -----------------------
2801    -- Write_Identifiers --
2802    -----------------------
2803
2804    function Write_Identifiers (Node : Node_Id) return Boolean is
2805    begin
2806       Sprint_Node (Defining_Identifier (Node));
2807
2808       --  The remainder of the declaration must be printed unless we are
2809       --  printing the original tree and this is not the last identifier
2810
2811       return
2812          not Dump_Original_Only or else not More_Ids (Node);
2813
2814    end Write_Identifiers;
2815
2816    ------------------------
2817    -- Write_Implicit_Def --
2818    ------------------------
2819
2820    procedure Write_Implicit_Def (E : Entity_Id) is
2821       Ind : Node_Id;
2822
2823    begin
2824       case Ekind (E) is
2825          when E_Array_Subtype =>
2826             Write_Str_With_Col_Check ("subtype ");
2827             Write_Id (E);
2828             Write_Str_With_Col_Check (" is ");
2829             Write_Id (Base_Type (E));
2830             Write_Str_With_Col_Check (" (");
2831
2832             Ind := First_Index (E);
2833
2834             while Present (Ind) loop
2835                Sprint_Node (Ind);
2836                Next_Index (Ind);
2837
2838                if Present (Ind) then
2839                   Write_Str (", ");
2840                end if;
2841             end loop;
2842
2843             Write_Str (");");
2844
2845          when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2846             Write_Str_With_Col_Check ("subtype ");
2847             Write_Id (E);
2848             Write_Str (" is ");
2849             Write_Id (Etype (E));
2850             Write_Str_With_Col_Check (" range ");
2851             Sprint_Node (Scalar_Range (E));
2852             Write_Str (";");
2853
2854          when others =>
2855             Write_Str_With_Col_Check ("type ");
2856             Write_Id (E);
2857             Write_Str_With_Col_Check (" is <");
2858             Write_Ekind (E);
2859             Write_Str (">;");
2860       end case;
2861
2862    end Write_Implicit_Def;
2863
2864    ------------------
2865    -- Write_Indent --
2866    ------------------
2867
2868    procedure Write_Indent is
2869    begin
2870       if Indent_Annull_Flag then
2871          Indent_Annull_Flag := False;
2872       else
2873          Write_Eol;
2874
2875          for J in 1 .. Indent loop
2876             Write_Char (' ');
2877          end loop;
2878       end if;
2879    end Write_Indent;
2880
2881    ------------------------------
2882    -- Write_Indent_Identifiers --
2883    ------------------------------
2884
2885    function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
2886    begin
2887       --  We need to start a new line for every node, except in the case
2888       --  where we are printing the original tree and this is not the first
2889       --  defining identifier in the list.
2890
2891       if not Dump_Original_Only or else not Prev_Ids (Node) then
2892          Write_Indent;
2893
2894       --  If printing original tree and this is not the first defining
2895       --  identifier in the list, then the previous call to this procedure
2896       --  printed only the name, and we add a comma to separate the names.
2897
2898       else
2899          Write_Str (", ");
2900       end if;
2901
2902       Sprint_Node (Defining_Identifier (Node));
2903
2904       --  The remainder of the declaration must be printed unless we are
2905       --  printing the original tree and this is not the last identifier
2906
2907       return
2908          not Dump_Original_Only or else not More_Ids (Node);
2909
2910    end Write_Indent_Identifiers;
2911
2912    -----------------------------------
2913    -- Write_Indent_Identifiers_Sloc --
2914    -----------------------------------
2915
2916    function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
2917    begin
2918       --  We need to start a new line for every node, except in the case
2919       --  where we are printing the original tree and this is not the first
2920       --  defining identifier in the list.
2921
2922       if not Dump_Original_Only or else not Prev_Ids (Node) then
2923          Write_Indent;
2924
2925       --  If printing original tree and this is not the first defining
2926       --  identifier in the list, then the previous call to this procedure
2927       --  printed only the name, and we add a comma to separate the names.
2928
2929       else
2930          Write_Str (", ");
2931       end if;
2932
2933       Set_Debug_Sloc;
2934       Sprint_Node (Defining_Identifier (Node));
2935
2936       --  The remainder of the declaration must be printed unless we are
2937       --  printing the original tree and this is not the last identifier
2938
2939       return
2940          not Dump_Original_Only or else not More_Ids (Node);
2941
2942    end Write_Indent_Identifiers_Sloc;
2943
2944    ----------------------
2945    -- Write_Indent_Str --
2946    ----------------------
2947
2948    procedure Write_Indent_Str (S : String) is
2949    begin
2950       Write_Indent;
2951       Write_Str (S);
2952    end Write_Indent_Str;
2953
2954    ---------------------------
2955    -- Write_Indent_Str_Sloc --
2956    ---------------------------
2957
2958    procedure Write_Indent_Str_Sloc (S : String) is
2959    begin
2960       Write_Indent;
2961       Write_Str_Sloc (S);
2962    end Write_Indent_Str_Sloc;
2963
2964    -------------------------------
2965    -- Write_Name_With_Col_Check --
2966    -------------------------------
2967
2968    procedure Write_Name_With_Col_Check (N : Name_Id) is
2969       J : Natural;
2970
2971    begin
2972       Get_Name_String (N);
2973
2974       --  Deal with -gnatI which replaces digits in an internal
2975       --  name by three dots (e.g. R7b becomes R...b).
2976
2977       if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
2978
2979          J := 2;
2980          while J < Name_Len loop
2981             exit when Name_Buffer (J) not in 'A' .. 'Z';
2982             J := J + 1;
2983          end loop;
2984
2985          if Name_Buffer (J) in '0' .. '9' then
2986             Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
2987             Write_Str ("...");
2988
2989             while J <= Name_Len loop
2990                if Name_Buffer (J) not in '0' .. '9' then
2991                   Write_Str (Name_Buffer (J .. Name_Len));
2992                   exit;
2993
2994                else
2995                   J := J + 1;
2996                end if;
2997             end loop;
2998
2999             return;
3000          end if;
3001       end if;
3002
3003       --  Fall through for normal case
3004
3005       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3006    end Write_Name_With_Col_Check;
3007
3008    ------------------------------------
3009    -- Write_Name_With_Col_Check_Sloc --
3010    ------------------------------------
3011
3012    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3013    begin
3014       Get_Name_String (N);
3015       Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3016    end Write_Name_With_Col_Check_Sloc;
3017
3018    --------------------
3019    -- Write_Operator --
3020    --------------------
3021
3022    procedure Write_Operator (N : Node_Id; S : String) is
3023       F : Natural := S'First;
3024       T : Natural := S'Last;
3025
3026    begin
3027       --  If no overflow check, just write string out, and we are done
3028
3029       if not Do_Overflow_Check (N) then
3030          Write_Str_Sloc (S);
3031
3032       --  If overflow check, we want to surround the operator with curly
3033       --  brackets, but not include spaces within the brackets.
3034
3035       else
3036          if S (F) = ' ' then
3037             Write_Char (' ');
3038             F := F + 1;
3039          end if;
3040
3041          if S (T) = ' ' then
3042             T := T - 1;
3043          end if;
3044
3045          Write_Char ('{');
3046          Write_Str_Sloc (S (F .. T));
3047          Write_Char ('}');
3048
3049          if S (S'Last) = ' ' then
3050             Write_Char (' ');
3051          end if;
3052       end if;
3053    end Write_Operator;
3054
3055    -----------------------
3056    -- Write_Param_Specs --
3057    -----------------------
3058
3059    procedure Write_Param_Specs (N : Node_Id) is
3060       Specs  : List_Id;
3061       Spec   : Node_Id;
3062       Formal : Node_Id;
3063
3064    begin
3065       Specs := Parameter_Specifications (N);
3066
3067       if Is_Non_Empty_List (Specs) then
3068          Write_Str_With_Col_Check (" (");
3069          Spec := First (Specs);
3070
3071          loop
3072             Sprint_Node (Spec);
3073             Formal := Defining_Identifier (Spec);
3074             Next (Spec);
3075             exit when Spec = Empty;
3076
3077             --  Add semicolon, unless we are printing original tree and the
3078             --  next specification is part of a list (but not the first
3079             --  element of that list)
3080
3081             if not Dump_Original_Only or else not Prev_Ids (Spec) then
3082                Write_Str ("; ");
3083             end if;
3084          end loop;
3085
3086          --  Write out any extra formals
3087
3088          while Present (Extra_Formal (Formal)) loop
3089             Formal := Extra_Formal (Formal);
3090             Write_Str ("; ");
3091             Write_Name_With_Col_Check (Chars (Formal));
3092             Write_Str (" : ");
3093             Write_Name_With_Col_Check (Chars (Etype (Formal)));
3094          end loop;
3095
3096          Write_Char (')');
3097       end if;
3098    end Write_Param_Specs;
3099
3100    --------------------------
3101    -- Write_Rewrite_Str --
3102    --------------------------
3103
3104    procedure Write_Rewrite_Str (S : String) is
3105    begin
3106       if not Dump_Generated_Only then
3107          if S'Length = 3 and then S = ">>>" then
3108             Write_Str (">>>");
3109          else
3110             Write_Str_With_Col_Check (S);
3111          end if;
3112       end if;
3113    end Write_Rewrite_Str;
3114
3115    --------------------
3116    -- Write_Str_Sloc --
3117    --------------------
3118
3119    procedure Write_Str_Sloc (S : String) is
3120    begin
3121       for J in S'Range loop
3122          Write_Char_Sloc (S (J));
3123       end loop;
3124    end Write_Str_Sloc;
3125
3126    ------------------------------
3127    -- Write_Str_With_Col_Check --
3128    ------------------------------
3129
3130    procedure Write_Str_With_Col_Check (S : String) is
3131    begin
3132       if Int (S'Last) + Column > Line_Limit then
3133          Write_Indent_Str ("  ");
3134
3135          if S (1) = ' ' then
3136             Write_Str (S (2 .. S'Length));
3137          else
3138             Write_Str (S);
3139          end if;
3140
3141       else
3142          Write_Str (S);
3143       end if;
3144    end Write_Str_With_Col_Check;
3145
3146    -----------------------------------
3147    -- Write_Str_With_Col_Check_Sloc --
3148    -----------------------------------
3149
3150    procedure Write_Str_With_Col_Check_Sloc (S : String) is
3151    begin
3152       if Int (S'Last) + Column > Line_Limit then
3153          Write_Indent_Str ("  ");
3154
3155          if S (1) = ' ' then
3156             Write_Str_Sloc (S (2 .. S'Length));
3157          else
3158             Write_Str_Sloc (S);
3159          end if;
3160
3161       else
3162          Write_Str_Sloc (S);
3163       end if;
3164    end Write_Str_With_Col_Check_Sloc;
3165
3166    ------------------------------------
3167    -- Write_Uint_With_Col_Check_Sloc --
3168    ------------------------------------
3169
3170    procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3171    begin
3172       Col_Check (UI_Decimal_Digits_Hi (U));
3173       Set_Debug_Sloc;
3174       UI_Write (U, Format);
3175    end Write_Uint_With_Col_Check_Sloc;
3176
3177    -------------------------------------
3178    -- Write_Ureal_With_Col_Check_Sloc --
3179    -------------------------------------
3180
3181    procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3182       D : constant Uint := Denominator (U);
3183       N : constant Uint := Numerator (U);
3184
3185    begin
3186       Col_Check
3187         (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3188       Set_Debug_Sloc;
3189       UR_Write (U);
3190    end Write_Ureal_With_Col_Check_Sloc;
3191
3192 end Sprint;