OSDN Git Service

2005-02-09 Robert Dewar <dewar@adacore.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-2005, 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 : constant 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
696             --  Ada 2005 (AI-254)
697
698             if Present (Access_To_Subprogram_Definition (Node)) then
699                Sprint_Node (Access_To_Subprogram_Definition (Node));
700             else
701                --  Ada 2005 (AI-231)
702
703                if Null_Exclusion_Present (Node) then
704                   Write_Str ("not null ");
705                end if;
706
707                Write_Str_With_Col_Check_Sloc ("access ");
708
709                if All_Present (Node) then
710                   Write_Str ("all ");
711                elsif Constant_Present (Node) then
712                   Write_Str ("constant ");
713                end if;
714
715                Sprint_Node (Subtype_Mark (Node));
716             end if;
717
718          when N_Access_Function_Definition =>
719
720             --  Ada 2005 (AI-231)
721
722             if Null_Exclusion_Present (Node) then
723                Write_Str ("not null ");
724             end if;
725
726             Write_Str_With_Col_Check_Sloc ("access ");
727
728             if Protected_Present (Node) then
729                Write_Str_With_Col_Check ("protected ");
730             end if;
731
732             Write_Str_With_Col_Check ("function");
733             Write_Param_Specs (Node);
734             Write_Str_With_Col_Check (" return ");
735             Sprint_Node (Subtype_Mark (Node));
736
737          when N_Access_Procedure_Definition =>
738
739             --  Ada 2005 (AI-231)
740
741             if Null_Exclusion_Present (Node) then
742                Write_Str ("not null ");
743             end if;
744
745             Write_Str_With_Col_Check_Sloc ("access ");
746
747             if Protected_Present (Node) then
748                Write_Str_With_Col_Check ("protected ");
749             end if;
750
751             Write_Str_With_Col_Check ("procedure");
752             Write_Param_Specs (Node);
753
754          when N_Access_To_Object_Definition =>
755             Write_Str_With_Col_Check_Sloc ("access ");
756
757             if All_Present (Node) then
758                Write_Str_With_Col_Check ("all ");
759             elsif Constant_Present (Node) then
760                Write_Str_With_Col_Check ("constant ");
761             end if;
762
763             --  Ada 2005 (AI-231)
764
765             if Null_Exclusion_Present (Node) then
766                Write_Str ("not null ");
767             end if;
768
769             Sprint_Node (Subtype_Indication (Node));
770
771          when N_Aggregate =>
772             if Null_Record_Present (Node) then
773                Write_Str_With_Col_Check_Sloc ("(null record)");
774
775             else
776                Write_Str_With_Col_Check_Sloc ("(");
777
778                if Present (Expressions (Node)) then
779                   Sprint_Comma_List (Expressions (Node));
780
781                   if Present (Component_Associations (Node)) then
782                      Write_Str (", ");
783                   end if;
784                end if;
785
786                if Present (Component_Associations (Node)) then
787                   Indent_Begin;
788
789                   declare
790                      Nd : Node_Id;
791
792                   begin
793                      Nd := First (Component_Associations (Node));
794
795                      loop
796                         Write_Indent;
797                         Sprint_Node (Nd);
798                         Next (Nd);
799                         exit when No (Nd);
800
801                         if not Is_Rewrite_Insertion (Nd)
802                           or else not Dump_Original_Only
803                         then
804                            Write_Str (", ");
805                         end if;
806                      end loop;
807                   end;
808
809                   Indent_End;
810                end if;
811
812                Write_Char (')');
813             end if;
814
815          when N_Allocator =>
816             Write_Str_With_Col_Check_Sloc ("new ");
817
818             --  Ada 2005 (AI-231)
819
820             if Null_Exclusion_Present (Node) then
821                Write_Str ("not null ");
822             end if;
823
824             Sprint_Node (Expression (Node));
825
826             if Present (Storage_Pool (Node)) then
827                Write_Str_With_Col_Check ("[storage_pool = ");
828                Sprint_Node (Storage_Pool (Node));
829                Write_Char (']');
830             end if;
831
832          when N_And_Then =>
833             Sprint_Left_Opnd (Node);
834             Write_Str_Sloc (" and then ");
835             Sprint_Right_Opnd (Node);
836
837          when N_At_Clause =>
838             Write_Indent_Str_Sloc ("for ");
839             Write_Id (Identifier (Node));
840             Write_Str_With_Col_Check (" use at ");
841             Sprint_Node (Expression (Node));
842             Write_Char (';');
843
844          when N_Assignment_Statement =>
845             Write_Indent;
846             Sprint_Node (Name (Node));
847             Write_Str_Sloc (" := ");
848             Sprint_Node (Expression (Node));
849             Write_Char (';');
850
851          when N_Asynchronous_Select =>
852             Write_Indent_Str_Sloc ("select");
853             Indent_Begin;
854             Sprint_Node (Triggering_Alternative (Node));
855             Indent_End;
856
857             --  Note: let the printing of Abortable_Part handle outputting
858             --  the ABORT keyword, so that the Slco can be set correctly.
859
860             Write_Indent_Str ("then ");
861             Sprint_Node (Abortable_Part (Node));
862             Write_Indent_Str ("end select;");
863
864          when N_Attribute_Definition_Clause =>
865             Write_Indent_Str_Sloc ("for ");
866             Sprint_Node (Name (Node));
867             Write_Char (''');
868             Write_Name_With_Col_Check (Chars (Node));
869             Write_Str_With_Col_Check (" use ");
870             Sprint_Node (Expression (Node));
871             Write_Char (';');
872
873          when N_Attribute_Reference =>
874             if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
875                Write_Indent;
876             end if;
877
878             Sprint_Node (Prefix (Node));
879             Write_Char_Sloc (''');
880             Write_Name_With_Col_Check (Attribute_Name (Node));
881             Sprint_Paren_Comma_List (Expressions (Node));
882
883             if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
884                Write_Char (';');
885             end if;
886
887          when N_Block_Statement =>
888             Write_Indent;
889
890             if Present (Identifier (Node))
891               and then (not Has_Created_Identifier (Node)
892                           or else not Dump_Original_Only)
893             then
894                Write_Rewrite_Str ("<<<");
895                Write_Id (Identifier (Node));
896                Write_Str (" : ");
897                Write_Rewrite_Str (">>>");
898             end if;
899
900             if Present (Declarations (Node)) then
901                Write_Str_With_Col_Check_Sloc ("declare");
902                Sprint_Indented_List (Declarations (Node));
903                Write_Indent;
904             end if;
905
906             Write_Str_With_Col_Check_Sloc ("begin");
907             Sprint_Node (Handled_Statement_Sequence (Node));
908             Write_Indent_Str ("end");
909
910             if Present (Identifier (Node))
911               and then (not Has_Created_Identifier (Node)
912                           or else not Dump_Original_Only)
913             then
914                Write_Rewrite_Str ("<<<");
915                Write_Char (' ');
916                Write_Id (Identifier (Node));
917                Write_Rewrite_Str (">>>");
918             end if;
919
920             Write_Char (';');
921
922          when N_Case_Statement =>
923             Write_Indent_Str_Sloc ("case ");
924             Sprint_Node (Expression (Node));
925             Write_Str (" is");
926             Sprint_Indented_List (Alternatives (Node));
927             Write_Indent_Str ("end case;");
928
929          when N_Case_Statement_Alternative =>
930             Write_Indent_Str_Sloc ("when ");
931             Sprint_Bar_List (Discrete_Choices (Node));
932             Write_Str (" => ");
933             Sprint_Indented_List (Statements (Node));
934
935          when N_Character_Literal =>
936             if Column > 70 then
937                Write_Indent_Str ("  ");
938             end if;
939
940             Write_Char_Sloc (''');
941             Write_Char_Code (UI_To_CC (Char_Literal_Value (Node)));
942             Write_Char (''');
943
944          when N_Code_Statement =>
945             Write_Indent;
946             Set_Debug_Sloc;
947             Sprint_Node (Expression (Node));
948             Write_Char (';');
949
950          when N_Compilation_Unit =>
951             Sprint_Node_List (Context_Items (Node));
952             Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
953
954             if Private_Present (Node) then
955                Write_Indent_Str ("private ");
956                Indent_Annull;
957             end if;
958
959             Sprint_Node_Sloc (Unit (Node));
960
961             if Present (Actions (Aux_Decls_Node (Node)))
962                  or else
963                Present (Pragmas_After (Aux_Decls_Node (Node)))
964             then
965                Write_Indent;
966             end if;
967
968             Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
969             Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
970
971          when N_Compilation_Unit_Aux =>
972             null; -- nothing to do, never used, see above
973
974          when N_Component_Association =>
975             Set_Debug_Sloc;
976             Sprint_Bar_List (Choices (Node));
977             Write_Str (" => ");
978
979             --  Ada 2005 (AI-287): Print the mbox if present
980
981             if Box_Present (Node) then
982                Write_Str_With_Col_Check ("<>");
983             else
984                Sprint_Node (Expression (Node));
985             end if;
986
987          when N_Component_Clause =>
988             Write_Indent;
989             Sprint_Node (Component_Name (Node));
990             Write_Str_Sloc (" at ");
991             Sprint_Node (Position (Node));
992             Write_Char (' ');
993             Write_Str_With_Col_Check ("range ");
994             Sprint_Node (First_Bit (Node));
995             Write_Str (" .. ");
996             Sprint_Node (Last_Bit (Node));
997             Write_Char (';');
998
999          when N_Component_Definition =>
1000             Set_Debug_Sloc;
1001
1002             --  Ada 2005 (AI-230): Access definition components
1003
1004             if Present (Access_Definition (Node)) then
1005                Sprint_Node (Access_Definition (Node));
1006
1007             elsif Present (Subtype_Indication (Node)) then
1008                if Aliased_Present (Node) then
1009                   Write_Str_With_Col_Check ("aliased ");
1010                end if;
1011
1012                --  Ada 2005 (AI-231)
1013
1014                if Null_Exclusion_Present (Node) then
1015                   Write_Str (" not null ");
1016                end if;
1017
1018                Sprint_Node (Subtype_Indication (Node));
1019
1020             else
1021                Write_Str (" ??? ");
1022             end if;
1023
1024          when N_Component_Declaration =>
1025             if Write_Indent_Identifiers_Sloc (Node) then
1026                Write_Str (" : ");
1027                Sprint_Node (Component_Definition (Node));
1028
1029                if Present (Expression (Node)) then
1030                   Write_Str (" := ");
1031                   Sprint_Node (Expression (Node));
1032                end if;
1033
1034                Write_Char (';');
1035             end if;
1036
1037          when N_Component_List =>
1038             if Null_Present (Node) then
1039                Indent_Begin;
1040                Write_Indent_Str_Sloc ("null");
1041                Write_Char (';');
1042                Indent_End;
1043
1044             else
1045                Set_Debug_Sloc;
1046                Sprint_Indented_List (Component_Items (Node));
1047                Sprint_Node (Variant_Part (Node));
1048             end if;
1049
1050          when N_Conditional_Entry_Call =>
1051             Write_Indent_Str_Sloc ("select");
1052             Indent_Begin;
1053             Sprint_Node (Entry_Call_Alternative (Node));
1054             Indent_End;
1055             Write_Indent_Str ("else");
1056             Sprint_Indented_List (Else_Statements (Node));
1057             Write_Indent_Str ("end select;");
1058
1059          when N_Conditional_Expression =>
1060             declare
1061                Condition : constant Node_Id := First (Expressions (Node));
1062                Then_Expr : constant Node_Id := Next (Condition);
1063                Else_Expr : constant Node_Id := Next (Then_Expr);
1064
1065             begin
1066                Write_Str_With_Col_Check_Sloc ("(if ");
1067                Sprint_Node (Condition);
1068                Write_Str_With_Col_Check (" then ");
1069                Sprint_Node (Then_Expr);
1070                Write_Str_With_Col_Check (" else ");
1071                Sprint_Node (Else_Expr);
1072                Write_Char (')');
1073             end;
1074
1075          when N_Constrained_Array_Definition =>
1076             Write_Str_With_Col_Check_Sloc ("array ");
1077             Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
1078             Write_Str (" of ");
1079
1080             Sprint_Node (Component_Definition (Node));
1081
1082          when N_Decimal_Fixed_Point_Definition =>
1083             Write_Str_With_Col_Check_Sloc (" delta ");
1084             Sprint_Node (Delta_Expression (Node));
1085             Write_Str_With_Col_Check ("digits ");
1086             Sprint_Node (Digits_Expression (Node));
1087             Sprint_Opt_Node (Real_Range_Specification (Node));
1088
1089          when N_Defining_Character_Literal =>
1090             Write_Name_With_Col_Check_Sloc (Chars (Node));
1091
1092          when N_Defining_Identifier =>
1093             Set_Debug_Sloc;
1094             Write_Id (Node);
1095
1096          when N_Defining_Operator_Symbol =>
1097             Write_Name_With_Col_Check_Sloc (Chars (Node));
1098
1099          when N_Defining_Program_Unit_Name =>
1100             Set_Debug_Sloc;
1101             Sprint_Node (Name (Node));
1102             Write_Char ('.');
1103             Write_Id (Defining_Identifier (Node));
1104
1105          when N_Delay_Alternative =>
1106             Sprint_Node_List (Pragmas_Before (Node));
1107
1108             if Present (Condition (Node)) then
1109                Write_Indent;
1110                Write_Str_With_Col_Check ("when ");
1111                Sprint_Node (Condition (Node));
1112                Write_Str (" => ");
1113                Indent_Annull;
1114             end if;
1115
1116             Sprint_Node_Sloc (Delay_Statement (Node));
1117             Sprint_Node_List (Statements (Node));
1118
1119          when N_Delay_Relative_Statement =>
1120             Write_Indent_Str_Sloc ("delay ");
1121             Sprint_Node (Expression (Node));
1122             Write_Char (';');
1123
1124          when N_Delay_Until_Statement =>
1125             Write_Indent_Str_Sloc ("delay until ");
1126             Sprint_Node (Expression (Node));
1127             Write_Char (';');
1128
1129          when N_Delta_Constraint =>
1130             Write_Str_With_Col_Check_Sloc ("delta ");
1131             Sprint_Node (Delta_Expression (Node));
1132             Sprint_Opt_Node (Range_Constraint (Node));
1133
1134          when N_Derived_Type_Definition =>
1135             if Abstract_Present (Node) then
1136                Write_Str_With_Col_Check ("abstract ");
1137             end if;
1138
1139             Write_Str_With_Col_Check_Sloc ("new ");
1140
1141             --  Ada 2005 (AI-231)
1142
1143             if Null_Exclusion_Present (Node) then
1144                Write_Str_With_Col_Check ("not null ");
1145             end if;
1146
1147             Sprint_Node (Subtype_Indication (Node));
1148
1149             if Present (Record_Extension_Part (Node)) then
1150                Write_Str_With_Col_Check (" with ");
1151                Sprint_Node (Record_Extension_Part (Node));
1152             end if;
1153
1154          when N_Designator =>
1155             Sprint_Node (Name (Node));
1156             Write_Char_Sloc ('.');
1157             Write_Id (Identifier (Node));
1158
1159          when N_Digits_Constraint =>
1160             Write_Str_With_Col_Check_Sloc ("digits ");
1161             Sprint_Node (Digits_Expression (Node));
1162             Sprint_Opt_Node (Range_Constraint (Node));
1163
1164          when N_Discriminant_Association =>
1165             Set_Debug_Sloc;
1166
1167             if Present (Selector_Names (Node)) then
1168                Sprint_Bar_List (Selector_Names (Node));
1169                Write_Str (" => ");
1170             end if;
1171
1172             Set_Debug_Sloc;
1173             Sprint_Node (Expression (Node));
1174
1175          when N_Discriminant_Specification =>
1176             Set_Debug_Sloc;
1177
1178             if Write_Identifiers (Node) then
1179                Write_Str (" : ");
1180
1181                if Null_Exclusion_Present (Node) then
1182                   Write_Str ("not null ");
1183                end if;
1184
1185                Sprint_Node (Discriminant_Type (Node));
1186
1187                if Present (Expression (Node)) then
1188                   Write_Str (" := ");
1189                   Sprint_Node (Expression (Node));
1190                end if;
1191             else
1192                Write_Str (", ");
1193             end if;
1194
1195          when N_Elsif_Part =>
1196             Write_Indent_Str_Sloc ("elsif ");
1197             Sprint_Node (Condition (Node));
1198             Write_Str_With_Col_Check (" then");
1199             Sprint_Indented_List (Then_Statements (Node));
1200
1201          when N_Empty =>
1202             null;
1203
1204          when N_Entry_Body =>
1205             Write_Indent_Str_Sloc ("entry ");
1206             Write_Id (Defining_Identifier (Node));
1207             Sprint_Node (Entry_Body_Formal_Part (Node));
1208             Write_Str_With_Col_Check (" is");
1209             Sprint_Indented_List (Declarations (Node));
1210             Write_Indent_Str ("begin");
1211             Sprint_Node (Handled_Statement_Sequence (Node));
1212             Write_Indent_Str ("end ");
1213             Write_Id (Defining_Identifier (Node));
1214             Write_Char (';');
1215
1216          when N_Entry_Body_Formal_Part =>
1217             if Present (Entry_Index_Specification (Node)) then
1218                Write_Str_With_Col_Check_Sloc (" (");
1219                Sprint_Node (Entry_Index_Specification (Node));
1220                Write_Char (')');
1221             end if;
1222
1223             Write_Param_Specs (Node);
1224             Write_Str_With_Col_Check_Sloc (" when ");
1225             Sprint_Node (Condition (Node));
1226
1227          when N_Entry_Call_Alternative =>
1228             Sprint_Node_List (Pragmas_Before (Node));
1229             Sprint_Node_Sloc (Entry_Call_Statement (Node));
1230             Sprint_Node_List (Statements (Node));
1231
1232          when N_Entry_Call_Statement =>
1233             Write_Indent;
1234             Sprint_Node_Sloc (Name (Node));
1235             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1236             Write_Char (';');
1237
1238          when N_Entry_Declaration =>
1239             Write_Indent_Str_Sloc ("entry ");
1240             Write_Id (Defining_Identifier (Node));
1241
1242             if Present (Discrete_Subtype_Definition (Node)) then
1243                Write_Str_With_Col_Check (" (");
1244                Sprint_Node (Discrete_Subtype_Definition (Node));
1245                Write_Char (')');
1246             end if;
1247
1248             Write_Param_Specs (Node);
1249             Write_Char (';');
1250
1251          when N_Entry_Index_Specification =>
1252             Write_Str_With_Col_Check_Sloc ("for ");
1253             Write_Id (Defining_Identifier (Node));
1254             Write_Str_With_Col_Check (" in ");
1255             Sprint_Node (Discrete_Subtype_Definition (Node));
1256
1257          when N_Enumeration_Representation_Clause =>
1258             Write_Indent_Str_Sloc ("for ");
1259             Write_Id (Identifier (Node));
1260             Write_Str_With_Col_Check (" use ");
1261             Sprint_Node (Array_Aggregate (Node));
1262             Write_Char (';');
1263
1264          when N_Enumeration_Type_Definition =>
1265             Set_Debug_Sloc;
1266
1267             --  Skip attempt to print Literals field if it's not there and
1268             --  we are in package Standard (case of Character, which is
1269             --  handled specially (without an explicit literals list).
1270
1271             if Sloc (Node) > Standard_Location
1272               or else Present (Literals (Node))
1273             then
1274                Sprint_Paren_Comma_List (Literals (Node));
1275             end if;
1276
1277          when N_Error =>
1278             Write_Str_With_Col_Check_Sloc ("<error>");
1279
1280          when N_Exception_Declaration =>
1281             if Write_Indent_Identifiers (Node) then
1282                Write_Str_With_Col_Check (" : ");
1283                Write_Str_Sloc ("exception;");
1284             end if;
1285
1286          when N_Exception_Handler =>
1287             Write_Indent_Str_Sloc ("when ");
1288
1289             if Present (Choice_Parameter (Node)) then
1290                Sprint_Node (Choice_Parameter (Node));
1291                Write_Str (" : ");
1292             end if;
1293
1294             Sprint_Bar_List (Exception_Choices (Node));
1295             Write_Str (" => ");
1296             Sprint_Indented_List (Statements (Node));
1297
1298          when N_Exception_Renaming_Declaration =>
1299             Write_Indent;
1300             Set_Debug_Sloc;
1301             Sprint_Node (Defining_Identifier (Node));
1302             Write_Str_With_Col_Check (" : exception renames ");
1303             Sprint_Node (Name (Node));
1304             Write_Char (';');
1305
1306          when N_Exit_Statement =>
1307             Write_Indent_Str_Sloc ("exit");
1308             Sprint_Opt_Node (Name (Node));
1309
1310             if Present (Condition (Node)) then
1311                Write_Str_With_Col_Check (" when ");
1312                Sprint_Node (Condition (Node));
1313             end if;
1314
1315             Write_Char (';');
1316
1317          when N_Expanded_Name =>
1318             Sprint_Node (Prefix (Node));
1319             Write_Char_Sloc ('.');
1320             Sprint_Node (Selector_Name (Node));
1321
1322          when N_Explicit_Dereference =>
1323             Sprint_Node (Prefix (Node));
1324             Write_Char_Sloc ('.');
1325             Write_Str_Sloc ("all");
1326
1327          when N_Extension_Aggregate =>
1328             Write_Str_With_Col_Check_Sloc ("(");
1329             Sprint_Node (Ancestor_Part (Node));
1330             Write_Str_With_Col_Check (" with ");
1331
1332             if Null_Record_Present (Node) then
1333                Write_Str_With_Col_Check ("null record");
1334             else
1335                if Present (Expressions (Node)) then
1336                   Sprint_Comma_List (Expressions (Node));
1337
1338                   if Present (Component_Associations (Node)) then
1339                      Write_Str (", ");
1340                   end if;
1341                end if;
1342
1343                if Present (Component_Associations (Node)) then
1344                   Sprint_Comma_List (Component_Associations (Node));
1345                end if;
1346             end if;
1347
1348             Write_Char (')');
1349
1350          when N_Floating_Point_Definition =>
1351             Write_Str_With_Col_Check_Sloc ("digits ");
1352             Sprint_Node (Digits_Expression (Node));
1353             Sprint_Opt_Node (Real_Range_Specification (Node));
1354
1355          when N_Formal_Decimal_Fixed_Point_Definition =>
1356             Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
1357
1358          when N_Formal_Derived_Type_Definition =>
1359             Write_Str_With_Col_Check_Sloc ("new ");
1360             Sprint_Node (Subtype_Mark (Node));
1361
1362             if Private_Present (Node) then
1363                Write_Str_With_Col_Check (" with private");
1364             end if;
1365
1366          when N_Formal_Abstract_Subprogram_Declaration =>
1367             Write_Indent_Str_Sloc ("with ");
1368             Sprint_Node (Specification (Node));
1369
1370             Write_Str_With_Col_Check (" is abstract");
1371
1372             if Box_Present (Node) then
1373                Write_Str_With_Col_Check (" <>");
1374             elsif Present (Default_Name (Node)) then
1375                Write_Str_With_Col_Check (" ");
1376                Sprint_Node (Default_Name (Node));
1377             end if;
1378
1379             Write_Char (';');
1380
1381          when N_Formal_Concrete_Subprogram_Declaration =>
1382             Write_Indent_Str_Sloc ("with ");
1383             Sprint_Node (Specification (Node));
1384
1385             if Box_Present (Node) then
1386                Write_Str_With_Col_Check (" is <>");
1387             elsif Present (Default_Name (Node)) then
1388                Write_Str_With_Col_Check (" is ");
1389                Sprint_Node (Default_Name (Node));
1390             end if;
1391
1392             Write_Char (';');
1393
1394          when N_Formal_Discrete_Type_Definition =>
1395             Write_Str_With_Col_Check_Sloc ("<>");
1396
1397          when N_Formal_Floating_Point_Definition =>
1398             Write_Str_With_Col_Check_Sloc ("digits <>");
1399
1400          when N_Formal_Modular_Type_Definition =>
1401             Write_Str_With_Col_Check_Sloc ("mod <>");
1402
1403          when N_Formal_Object_Declaration =>
1404             Set_Debug_Sloc;
1405
1406             if Write_Indent_Identifiers (Node) then
1407                Write_Str (" : ");
1408
1409                if In_Present (Node) then
1410                   Write_Str_With_Col_Check ("in ");
1411                end if;
1412
1413                if Out_Present (Node) then
1414                   Write_Str_With_Col_Check ("out ");
1415                end if;
1416
1417                Sprint_Node (Subtype_Mark (Node));
1418
1419                if Present (Expression (Node)) then
1420                   Write_Str (" := ");
1421                   Sprint_Node (Expression (Node));
1422                end if;
1423
1424                Write_Char (';');
1425             end if;
1426
1427          when N_Formal_Ordinary_Fixed_Point_Definition =>
1428             Write_Str_With_Col_Check_Sloc ("delta <>");
1429
1430          when N_Formal_Package_Declaration =>
1431             Write_Indent_Str_Sloc ("with package ");
1432             Write_Id (Defining_Identifier (Node));
1433             Write_Str_With_Col_Check (" is new ");
1434             Sprint_Node (Name (Node));
1435             Write_Str_With_Col_Check (" (<>);");
1436
1437          when N_Formal_Private_Type_Definition =>
1438             if Abstract_Present (Node) then
1439                Write_Str_With_Col_Check ("abstract ");
1440             end if;
1441
1442             if Tagged_Present (Node) then
1443                Write_Str_With_Col_Check ("tagged ");
1444             end if;
1445
1446             if Limited_Present (Node) then
1447                Write_Str_With_Col_Check ("limited ");
1448             end if;
1449
1450             Write_Str_With_Col_Check_Sloc ("private");
1451
1452          when N_Formal_Signed_Integer_Type_Definition =>
1453             Write_Str_With_Col_Check_Sloc ("range <>");
1454
1455          when N_Formal_Type_Declaration =>
1456             Write_Indent_Str_Sloc ("type ");
1457             Write_Id (Defining_Identifier (Node));
1458
1459             if Present (Discriminant_Specifications (Node)) then
1460                Write_Discr_Specs (Node);
1461             elsif Unknown_Discriminants_Present (Node) then
1462                Write_Str_With_Col_Check ("(<>)");
1463             end if;
1464
1465             Write_Str_With_Col_Check (" is ");
1466             Sprint_Node (Formal_Type_Definition (Node));
1467             Write_Char (';');
1468
1469          when N_Free_Statement =>
1470             Write_Indent_Str_Sloc ("free ");
1471             Sprint_Node (Expression (Node));
1472             Write_Char (';');
1473
1474          when N_Freeze_Entity =>
1475             if Dump_Original_Only then
1476                null;
1477
1478             elsif Present (Actions (Node)) or else Dump_Freeze_Null then
1479                Write_Indent;
1480                Write_Rewrite_Str ("<<<");
1481                Write_Str_With_Col_Check_Sloc ("freeze ");
1482                Write_Id (Entity (Node));
1483                Write_Str (" [");
1484
1485                if No (Actions (Node)) then
1486                   Write_Char (']');
1487
1488                else
1489                   Freeze_Indent := Freeze_Indent + 1;
1490                   Sprint_Indented_List (Actions (Node));
1491                   Freeze_Indent := Freeze_Indent - 1;
1492                   Write_Indent_Str ("]");
1493                end if;
1494
1495                Write_Rewrite_Str (">>>");
1496             end if;
1497
1498          when N_Full_Type_Declaration =>
1499             Write_Indent_Str_Sloc ("type ");
1500             Write_Id (Defining_Identifier (Node));
1501             Write_Discr_Specs (Node);
1502             Write_Str_With_Col_Check (" is ");
1503             Sprint_Node (Type_Definition (Node));
1504             Write_Char (';');
1505
1506          when N_Function_Call =>
1507             Set_Debug_Sloc;
1508             Sprint_Node (Name (Node));
1509             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
1510
1511          when N_Function_Instantiation =>
1512             Write_Indent_Str_Sloc ("function ");
1513             Sprint_Node (Defining_Unit_Name (Node));
1514             Write_Str_With_Col_Check (" is new ");
1515             Sprint_Node (Name (Node));
1516             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1517             Write_Char (';');
1518
1519          when N_Function_Specification =>
1520             Write_Str_With_Col_Check_Sloc ("function ");
1521             Sprint_Node (Defining_Unit_Name (Node));
1522             Write_Param_Specs (Node);
1523             Write_Str_With_Col_Check (" return ");
1524             Sprint_Node (Subtype_Mark (Node));
1525
1526          when N_Generic_Association =>
1527             Set_Debug_Sloc;
1528
1529             if Present (Selector_Name (Node)) then
1530                Sprint_Node (Selector_Name (Node));
1531                Write_Str (" => ");
1532             end if;
1533
1534             Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
1535
1536          when N_Generic_Function_Renaming_Declaration =>
1537             Write_Indent_Str_Sloc ("generic function ");
1538             Sprint_Node (Defining_Unit_Name (Node));
1539             Write_Str_With_Col_Check (" renames ");
1540             Sprint_Node (Name (Node));
1541             Write_Char (';');
1542
1543          when N_Generic_Package_Declaration =>
1544             Write_Indent;
1545             Write_Indent_Str_Sloc ("generic ");
1546             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1547             Write_Indent;
1548             Sprint_Node (Specification (Node));
1549             Write_Char (';');
1550
1551          when N_Generic_Package_Renaming_Declaration =>
1552             Write_Indent_Str_Sloc ("generic package ");
1553             Sprint_Node (Defining_Unit_Name (Node));
1554             Write_Str_With_Col_Check (" renames ");
1555             Sprint_Node (Name (Node));
1556             Write_Char (';');
1557
1558          when N_Generic_Procedure_Renaming_Declaration =>
1559             Write_Indent_Str_Sloc ("generic procedure ");
1560             Sprint_Node (Defining_Unit_Name (Node));
1561             Write_Str_With_Col_Check (" renames ");
1562             Sprint_Node (Name (Node));
1563             Write_Char (';');
1564
1565          when N_Generic_Subprogram_Declaration =>
1566             Write_Indent;
1567             Write_Indent_Str_Sloc ("generic ");
1568             Sprint_Indented_List (Generic_Formal_Declarations (Node));
1569             Write_Indent;
1570             Sprint_Node (Specification (Node));
1571             Write_Char (';');
1572
1573          when N_Goto_Statement =>
1574             Write_Indent_Str_Sloc ("goto ");
1575             Sprint_Node (Name (Node));
1576             Write_Char (';');
1577
1578             if Nkind (Next (Node)) = N_Label then
1579                Write_Indent;
1580             end if;
1581
1582          when N_Handled_Sequence_Of_Statements =>
1583             Set_Debug_Sloc;
1584             Sprint_Indented_List (Statements (Node));
1585
1586             if Present (Exception_Handlers (Node)) then
1587                Write_Indent_Str ("exception");
1588                Indent_Begin;
1589                Sprint_Node_List (Exception_Handlers (Node));
1590                Indent_End;
1591             end if;
1592
1593             if Present (At_End_Proc (Node)) then
1594                Write_Indent_Str ("at end");
1595                Indent_Begin;
1596                Write_Indent;
1597                Sprint_Node (At_End_Proc (Node));
1598                Write_Char (';');
1599                Indent_End;
1600             end if;
1601
1602          when N_Identifier =>
1603             Set_Debug_Sloc;
1604             Write_Id (Node);
1605
1606          when N_If_Statement =>
1607             Write_Indent_Str_Sloc ("if ");
1608             Sprint_Node (Condition (Node));
1609             Write_Str_With_Col_Check (" then");
1610             Sprint_Indented_List (Then_Statements (Node));
1611             Sprint_Opt_Node_List (Elsif_Parts (Node));
1612
1613             if Present (Else_Statements (Node)) then
1614                Write_Indent_Str ("else");
1615                Sprint_Indented_List (Else_Statements (Node));
1616             end if;
1617
1618             Write_Indent_Str ("end if;");
1619
1620          when N_Implicit_Label_Declaration =>
1621             if not Dump_Original_Only then
1622                Write_Indent;
1623                Write_Rewrite_Str ("<<<");
1624                Set_Debug_Sloc;
1625                Write_Id (Defining_Identifier (Node));
1626                Write_Str (" : ");
1627                Write_Str_With_Col_Check ("label");
1628                Write_Rewrite_Str (">>>");
1629             end if;
1630
1631          when N_In =>
1632             Sprint_Left_Opnd (Node);
1633             Write_Str_Sloc (" in ");
1634             Sprint_Right_Opnd (Node);
1635
1636          when N_Incomplete_Type_Declaration =>
1637             Write_Indent_Str_Sloc ("type ");
1638             Write_Id (Defining_Identifier (Node));
1639
1640             if Present (Discriminant_Specifications (Node)) then
1641                Write_Discr_Specs (Node);
1642             elsif Unknown_Discriminants_Present (Node) then
1643                Write_Str_With_Col_Check ("(<>)");
1644             end if;
1645
1646             Write_Char (';');
1647
1648          when N_Index_Or_Discriminant_Constraint =>
1649             Set_Debug_Sloc;
1650             Sprint_Paren_Comma_List (Constraints (Node));
1651
1652          when N_Indexed_Component =>
1653             Sprint_Node_Sloc (Prefix (Node));
1654             Sprint_Opt_Paren_Comma_List (Expressions (Node));
1655
1656          when N_Integer_Literal =>
1657             if Print_In_Hex (Node) then
1658                Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
1659             else
1660                Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
1661             end if;
1662
1663          when N_Iteration_Scheme =>
1664             if Present (Condition (Node)) then
1665                Write_Str_With_Col_Check_Sloc ("while ");
1666                Sprint_Node (Condition (Node));
1667             else
1668                Write_Str_With_Col_Check_Sloc ("for ");
1669                Sprint_Node (Loop_Parameter_Specification (Node));
1670             end if;
1671
1672             Write_Char (' ');
1673
1674          when N_Itype_Reference =>
1675             Write_Indent_Str_Sloc ("reference ");
1676             Write_Id (Itype (Node));
1677
1678          when N_Label =>
1679             Write_Indent_Str_Sloc ("<<");
1680             Write_Id (Identifier (Node));
1681             Write_Str (">>");
1682
1683          when N_Loop_Parameter_Specification =>
1684             Set_Debug_Sloc;
1685             Write_Id (Defining_Identifier (Node));
1686             Write_Str_With_Col_Check (" in ");
1687
1688             if Reverse_Present (Node) then
1689                Write_Str_With_Col_Check ("reverse ");
1690             end if;
1691
1692             Sprint_Node (Discrete_Subtype_Definition (Node));
1693
1694          when N_Loop_Statement =>
1695             Write_Indent;
1696
1697             if Present (Identifier (Node))
1698               and then (not Has_Created_Identifier (Node)
1699                           or else not Dump_Original_Only)
1700             then
1701                Write_Rewrite_Str ("<<<");
1702                Write_Id (Identifier (Node));
1703                Write_Str (" : ");
1704                Write_Rewrite_Str (">>>");
1705                Sprint_Node (Iteration_Scheme (Node));
1706                Write_Str_With_Col_Check_Sloc ("loop");
1707                Sprint_Indented_List (Statements (Node));
1708                Write_Indent_Str ("end loop ");
1709                Write_Rewrite_Str ("<<<");
1710                Write_Id (Identifier (Node));
1711                Write_Rewrite_Str (">>>");
1712                Write_Char (';');
1713
1714             else
1715                Sprint_Node (Iteration_Scheme (Node));
1716                Write_Str_With_Col_Check_Sloc ("loop");
1717                Sprint_Indented_List (Statements (Node));
1718                Write_Indent_Str ("end loop;");
1719             end if;
1720
1721          when N_Mod_Clause =>
1722             Sprint_Node_List (Pragmas_Before (Node));
1723             Write_Str_With_Col_Check_Sloc ("at mod ");
1724             Sprint_Node (Expression (Node));
1725
1726          when N_Modular_Type_Definition =>
1727             Write_Str_With_Col_Check_Sloc ("mod ");
1728             Sprint_Node (Expression (Node));
1729
1730          when N_Not_In =>
1731             Sprint_Left_Opnd (Node);
1732             Write_Str_Sloc (" not in ");
1733             Sprint_Right_Opnd (Node);
1734
1735          when N_Null =>
1736             Write_Str_With_Col_Check_Sloc ("null");
1737
1738          when N_Null_Statement =>
1739             if Comes_From_Source (Node)
1740               or else Dump_Freeze_Null
1741               or else not Is_List_Member (Node)
1742               or else (No (Prev (Node)) and then No (Next (Node)))
1743             then
1744                Write_Indent_Str_Sloc ("null;");
1745             end if;
1746
1747          when N_Number_Declaration =>
1748             Set_Debug_Sloc;
1749
1750             if Write_Indent_Identifiers (Node) then
1751                Write_Str_With_Col_Check (" : constant ");
1752                Write_Str (" := ");
1753                Sprint_Node (Expression (Node));
1754                Write_Char (';');
1755             end if;
1756
1757          when N_Object_Declaration =>
1758             Set_Debug_Sloc;
1759
1760             if Write_Indent_Identifiers (Node) then
1761                Write_Str (" : ");
1762
1763                if Aliased_Present (Node) then
1764                   Write_Str_With_Col_Check ("aliased ");
1765                end if;
1766
1767                if Constant_Present (Node) then
1768                   Write_Str_With_Col_Check ("constant ");
1769                end if;
1770
1771                --  Ada 2005 (AI-231)
1772
1773                if Null_Exclusion_Present (Node) then
1774                   Write_Str_With_Col_Check ("not null ");
1775                end if;
1776
1777                Sprint_Node (Object_Definition (Node));
1778
1779                if Present (Expression (Node)) then
1780                   Write_Str (" := ");
1781                   Sprint_Node (Expression (Node));
1782                end if;
1783
1784                Write_Char (';');
1785             end if;
1786
1787          when N_Object_Renaming_Declaration =>
1788             Write_Indent;
1789             Set_Debug_Sloc;
1790             Sprint_Node (Defining_Identifier (Node));
1791             Write_Str (" : ");
1792
1793             --  Ada 2005 (AI-230): Access renamings
1794
1795             if Present (Access_Definition (Node)) then
1796                Sprint_Node (Access_Definition (Node));
1797
1798             elsif Present (Subtype_Mark (Node)) then
1799                Sprint_Node (Subtype_Mark (Node));
1800
1801             else
1802                Write_Str (" ??? ");
1803             end if;
1804
1805             Write_Str_With_Col_Check (" renames ");
1806             Sprint_Node (Name (Node));
1807             Write_Char (';');
1808
1809          when N_Op_Abs =>
1810             Write_Operator (Node, "abs ");
1811             Sprint_Right_Opnd (Node);
1812
1813          when N_Op_Add =>
1814             Sprint_Left_Opnd (Node);
1815             Write_Operator (Node, " + ");
1816             Sprint_Right_Opnd (Node);
1817
1818          when N_Op_And =>
1819             Sprint_Left_Opnd (Node);
1820             Write_Operator (Node, " and ");
1821             Sprint_Right_Opnd (Node);
1822
1823          when N_Op_Concat =>
1824             Sprint_Left_Opnd (Node);
1825             Write_Operator (Node, " & ");
1826             Sprint_Right_Opnd (Node);
1827
1828          when N_Op_Divide =>
1829             Sprint_Left_Opnd (Node);
1830             Write_Char (' ');
1831             Process_TFAI_RR_Flags (Node);
1832             Write_Operator (Node, "/ ");
1833             Sprint_Right_Opnd (Node);
1834
1835          when N_Op_Eq =>
1836             Sprint_Left_Opnd (Node);
1837             Write_Operator (Node, " = ");
1838             Sprint_Right_Opnd (Node);
1839
1840          when N_Op_Expon =>
1841             Sprint_Left_Opnd (Node);
1842             Write_Operator (Node, " ** ");
1843             Sprint_Right_Opnd (Node);
1844
1845          when N_Op_Ge =>
1846             Sprint_Left_Opnd (Node);
1847             Write_Operator (Node, " >= ");
1848             Sprint_Right_Opnd (Node);
1849
1850          when N_Op_Gt =>
1851             Sprint_Left_Opnd (Node);
1852             Write_Operator (Node, " > ");
1853             Sprint_Right_Opnd (Node);
1854
1855          when N_Op_Le =>
1856             Sprint_Left_Opnd (Node);
1857             Write_Operator (Node, " <= ");
1858             Sprint_Right_Opnd (Node);
1859
1860          when N_Op_Lt =>
1861             Sprint_Left_Opnd (Node);
1862             Write_Operator (Node, " < ");
1863             Sprint_Right_Opnd (Node);
1864
1865          when N_Op_Minus =>
1866             Write_Operator (Node, "-");
1867             Sprint_Right_Opnd (Node);
1868
1869          when N_Op_Mod =>
1870             Sprint_Left_Opnd (Node);
1871
1872             if Treat_Fixed_As_Integer (Node) then
1873                Write_Str (" #");
1874             end if;
1875
1876             Write_Operator (Node, " mod ");
1877             Sprint_Right_Opnd (Node);
1878
1879          when N_Op_Multiply =>
1880             Sprint_Left_Opnd (Node);
1881             Write_Char (' ');
1882             Process_TFAI_RR_Flags (Node);
1883             Write_Operator (Node, "* ");
1884             Sprint_Right_Opnd (Node);
1885
1886          when N_Op_Ne =>
1887             Sprint_Left_Opnd (Node);
1888             Write_Operator (Node, " /= ");
1889             Sprint_Right_Opnd (Node);
1890
1891          when N_Op_Not =>
1892             Write_Operator (Node, "not ");
1893             Sprint_Right_Opnd (Node);
1894
1895          when N_Op_Or =>
1896             Sprint_Left_Opnd (Node);
1897             Write_Operator (Node, " or ");
1898             Sprint_Right_Opnd (Node);
1899
1900          when N_Op_Plus =>
1901             Write_Operator (Node, "+");
1902             Sprint_Right_Opnd (Node);
1903
1904          when N_Op_Rem =>
1905             Sprint_Left_Opnd (Node);
1906
1907             if Treat_Fixed_As_Integer (Node) then
1908                Write_Str (" #");
1909             end if;
1910
1911             Write_Operator (Node, " rem ");
1912             Sprint_Right_Opnd (Node);
1913
1914          when N_Op_Shift =>
1915             Set_Debug_Sloc;
1916             Write_Id (Node);
1917             Write_Char ('!');
1918             Write_Str_With_Col_Check ("(");
1919             Sprint_Node (Left_Opnd (Node));
1920             Write_Str (", ");
1921             Sprint_Node (Right_Opnd (Node));
1922             Write_Char (')');
1923
1924          when N_Op_Subtract =>
1925             Sprint_Left_Opnd (Node);
1926             Write_Operator (Node, " - ");
1927             Sprint_Right_Opnd (Node);
1928
1929          when N_Op_Xor =>
1930             Sprint_Left_Opnd (Node);
1931             Write_Operator (Node, " xor ");
1932             Sprint_Right_Opnd (Node);
1933
1934          when N_Operator_Symbol =>
1935             Write_Name_With_Col_Check_Sloc (Chars (Node));
1936
1937          when N_Ordinary_Fixed_Point_Definition =>
1938             Write_Str_With_Col_Check_Sloc ("delta ");
1939             Sprint_Node (Delta_Expression (Node));
1940             Sprint_Opt_Node (Real_Range_Specification (Node));
1941
1942          when N_Or_Else =>
1943             Sprint_Left_Opnd (Node);
1944             Write_Str_Sloc (" or else ");
1945             Sprint_Right_Opnd (Node);
1946
1947          when N_Others_Choice =>
1948             if All_Others (Node) then
1949                Write_Str_With_Col_Check ("all ");
1950             end if;
1951
1952             Write_Str_With_Col_Check_Sloc ("others");
1953
1954          when N_Package_Body =>
1955             Write_Indent;
1956             Write_Indent_Str_Sloc ("package body ");
1957             Sprint_Node (Defining_Unit_Name (Node));
1958             Write_Str (" is");
1959             Sprint_Indented_List (Declarations (Node));
1960
1961             if Present (Handled_Statement_Sequence (Node)) then
1962                Write_Indent_Str ("begin");
1963                Sprint_Node (Handled_Statement_Sequence (Node));
1964             end if;
1965
1966             Write_Indent_Str ("end ");
1967             Sprint_Node (Defining_Unit_Name (Node));
1968             Write_Char (';');
1969
1970          when N_Package_Body_Stub =>
1971             Write_Indent_Str_Sloc ("package body ");
1972             Sprint_Node (Defining_Identifier (Node));
1973             Write_Str_With_Col_Check (" is separate;");
1974
1975          when N_Package_Declaration =>
1976             Write_Indent;
1977             Write_Indent;
1978             Sprint_Node_Sloc (Specification (Node));
1979             Write_Char (';');
1980
1981          when N_Package_Instantiation =>
1982             Write_Indent;
1983             Write_Indent_Str_Sloc ("package ");
1984             Sprint_Node (Defining_Unit_Name (Node));
1985             Write_Str (" is new ");
1986             Sprint_Node (Name (Node));
1987             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
1988             Write_Char (';');
1989
1990          when N_Package_Renaming_Declaration =>
1991             Write_Indent_Str_Sloc ("package ");
1992             Sprint_Node (Defining_Unit_Name (Node));
1993             Write_Str_With_Col_Check (" renames ");
1994             Sprint_Node (Name (Node));
1995             Write_Char (';');
1996
1997          when N_Package_Specification =>
1998             Write_Str_With_Col_Check_Sloc ("package ");
1999             Sprint_Node (Defining_Unit_Name (Node));
2000             Write_Str (" is");
2001             Sprint_Indented_List (Visible_Declarations (Node));
2002
2003             if Present (Private_Declarations (Node)) then
2004                Write_Indent_Str ("private");
2005                Sprint_Indented_List (Private_Declarations (Node));
2006             end if;
2007
2008             Write_Indent_Str ("end ");
2009             Sprint_Node (Defining_Unit_Name (Node));
2010
2011          when N_Parameter_Association =>
2012             Sprint_Node_Sloc (Selector_Name (Node));
2013             Write_Str (" => ");
2014             Sprint_Node (Explicit_Actual_Parameter (Node));
2015
2016          when N_Parameter_Specification =>
2017             Set_Debug_Sloc;
2018
2019             if Write_Identifiers (Node) then
2020                Write_Str (" : ");
2021
2022                if In_Present (Node) then
2023                   Write_Str_With_Col_Check ("in ");
2024                end if;
2025
2026                if Out_Present (Node) then
2027                   Write_Str_With_Col_Check ("out ");
2028                end if;
2029
2030                --  Ada 2005 (AI-231)
2031
2032                if Null_Exclusion_Present (Node) then
2033                   Write_Str ("not null ");
2034                end if;
2035
2036                Sprint_Node (Parameter_Type (Node));
2037
2038                if Present (Expression (Node)) then
2039                   Write_Str (" := ");
2040                   Sprint_Node (Expression (Node));
2041                end if;
2042             else
2043                Write_Str (", ");
2044             end if;
2045
2046          when N_Pragma =>
2047             Write_Indent_Str_Sloc ("pragma ");
2048             Write_Name_With_Col_Check (Chars (Node));
2049
2050             if Present (Pragma_Argument_Associations (Node)) then
2051                Sprint_Opt_Paren_Comma_List
2052                  (Pragma_Argument_Associations (Node));
2053             end if;
2054
2055             Write_Char (';');
2056
2057          when N_Pragma_Argument_Association =>
2058             Set_Debug_Sloc;
2059
2060             if Chars (Node) /= No_Name then
2061                Write_Name_With_Col_Check (Chars (Node));
2062                Write_Str (" => ");
2063             end if;
2064
2065             Sprint_Node (Expression (Node));
2066
2067          when N_Private_Type_Declaration =>
2068             Write_Indent_Str_Sloc ("type ");
2069             Write_Id (Defining_Identifier (Node));
2070
2071             if Present (Discriminant_Specifications (Node)) then
2072                Write_Discr_Specs (Node);
2073             elsif Unknown_Discriminants_Present (Node) then
2074                Write_Str_With_Col_Check ("(<>)");
2075             end if;
2076
2077             Write_Str (" is ");
2078
2079             if Tagged_Present (Node) then
2080                Write_Str_With_Col_Check ("tagged ");
2081             end if;
2082
2083             if Limited_Present (Node) then
2084                Write_Str_With_Col_Check ("limited ");
2085             end if;
2086
2087             Write_Str_With_Col_Check ("private;");
2088
2089          when N_Private_Extension_Declaration =>
2090             Write_Indent_Str_Sloc ("type ");
2091             Write_Id (Defining_Identifier (Node));
2092
2093             if Present (Discriminant_Specifications (Node)) then
2094                Write_Discr_Specs (Node);
2095             elsif Unknown_Discriminants_Present (Node) then
2096                Write_Str_With_Col_Check ("(<>)");
2097             end if;
2098
2099             Write_Str_With_Col_Check (" is new ");
2100             Sprint_Node (Subtype_Indication (Node));
2101             Write_Str_With_Col_Check (" with private;");
2102
2103          when N_Procedure_Call_Statement =>
2104             Write_Indent;
2105             Set_Debug_Sloc;
2106             Sprint_Node (Name (Node));
2107             Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
2108             Write_Char (';');
2109
2110          when N_Procedure_Instantiation =>
2111             Write_Indent_Str_Sloc ("procedure ");
2112             Sprint_Node (Defining_Unit_Name (Node));
2113             Write_Str_With_Col_Check (" is new ");
2114             Sprint_Node (Name (Node));
2115             Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
2116             Write_Char (';');
2117
2118          when N_Procedure_Specification =>
2119             Write_Str_With_Col_Check_Sloc ("procedure ");
2120             Sprint_Node (Defining_Unit_Name (Node));
2121             Write_Param_Specs (Node);
2122
2123          when N_Protected_Body =>
2124             Write_Indent_Str_Sloc ("protected body ");
2125             Write_Id (Defining_Identifier (Node));
2126             Write_Str (" is");
2127             Sprint_Indented_List (Declarations (Node));
2128             Write_Indent_Str ("end ");
2129             Write_Id (Defining_Identifier (Node));
2130             Write_Char (';');
2131
2132          when N_Protected_Body_Stub =>
2133             Write_Indent_Str_Sloc ("protected body ");
2134             Write_Id (Defining_Identifier (Node));
2135             Write_Str_With_Col_Check (" is separate;");
2136
2137          when N_Protected_Definition =>
2138             Set_Debug_Sloc;
2139             Sprint_Indented_List (Visible_Declarations (Node));
2140
2141             if Present (Private_Declarations (Node)) then
2142                Write_Indent_Str ("private");
2143                Sprint_Indented_List (Private_Declarations (Node));
2144             end if;
2145
2146             Write_Indent_Str ("end ");
2147
2148          when N_Protected_Type_Declaration =>
2149             Write_Indent_Str_Sloc ("protected type ");
2150             Write_Id (Defining_Identifier (Node));
2151             Write_Discr_Specs (Node);
2152             Write_Str (" is");
2153             Sprint_Node (Protected_Definition (Node));
2154             Write_Id (Defining_Identifier (Node));
2155             Write_Char (';');
2156
2157          when N_Qualified_Expression =>
2158             Sprint_Node (Subtype_Mark (Node));
2159             Write_Char_Sloc (''');
2160
2161             --  Print expression, make sure we have at least one level of
2162             --  parentheses around the expression. For cases of qualified
2163             --  expressions in the source, this is always the case, but
2164             --  for generated qualifications, there may be no explicit
2165             --  parentheses present.
2166
2167             if Paren_Count (Expression (Node)) /= 0 then
2168                Sprint_Node (Expression (Node));
2169             else
2170                Write_Char ('(');
2171                Sprint_Node (Expression (Node));
2172                Write_Char (')');
2173             end if;
2174
2175          when N_Raise_Constraint_Error =>
2176
2177             --  This node can be used either as a subexpression or as a
2178             --  statement form. The following test is a reasonably reliable
2179             --  way to distinguish the two cases.
2180
2181             if Is_List_Member (Node)
2182               and then Nkind (Parent (Node)) not in N_Subexpr
2183             then
2184                Write_Indent;
2185             end if;
2186
2187             Write_Str_With_Col_Check_Sloc ("[constraint_error");
2188             Write_Condition_And_Reason (Node);
2189
2190          when N_Raise_Program_Error =>
2191
2192             --  This node can be used either as a subexpression or as a
2193             --  statement form. The following test is a reasonably reliable
2194             --  way to distinguish the two cases.
2195
2196             if Is_List_Member (Node)
2197               and then Nkind (Parent (Node)) not in N_Subexpr
2198             then
2199                Write_Indent;
2200             end if;
2201
2202             Write_Str_With_Col_Check_Sloc ("[program_error");
2203             Write_Condition_And_Reason (Node);
2204
2205          when N_Raise_Storage_Error =>
2206
2207             --  This node can be used either as a subexpression or as a
2208             --  statement form. The following test is a reasonably reliable
2209             --  way to distinguish the two cases.
2210
2211             if Is_List_Member (Node)
2212               and then Nkind (Parent (Node)) not in N_Subexpr
2213             then
2214                Write_Indent;
2215             end if;
2216
2217             Write_Str_With_Col_Check_Sloc ("[storage_error");
2218             Write_Condition_And_Reason (Node);
2219
2220          when N_Raise_Statement =>
2221             Write_Indent_Str_Sloc ("raise ");
2222             Sprint_Node (Name (Node));
2223             Write_Char (';');
2224
2225          when N_Range =>
2226             Sprint_Node (Low_Bound (Node));
2227             Write_Str_Sloc (" .. ");
2228             Sprint_Node (High_Bound (Node));
2229
2230          when N_Range_Constraint =>
2231             Write_Str_With_Col_Check_Sloc ("range ");
2232             Sprint_Node (Range_Expression (Node));
2233
2234          when N_Real_Literal =>
2235             Write_Ureal_With_Col_Check_Sloc (Realval (Node));
2236
2237          when N_Real_Range_Specification =>
2238             Write_Str_With_Col_Check_Sloc ("range ");
2239             Sprint_Node (Low_Bound (Node));
2240             Write_Str (" .. ");
2241             Sprint_Node (High_Bound (Node));
2242
2243          when N_Record_Definition =>
2244             if Abstract_Present (Node) then
2245                Write_Str_With_Col_Check ("abstract ");
2246             end if;
2247
2248             if Tagged_Present (Node) then
2249                Write_Str_With_Col_Check ("tagged ");
2250             end if;
2251
2252             if Limited_Present (Node) then
2253                Write_Str_With_Col_Check ("limited ");
2254             end if;
2255
2256             if Null_Present (Node) then
2257                Write_Str_With_Col_Check_Sloc ("null record");
2258
2259             else
2260                Write_Str_With_Col_Check_Sloc ("record");
2261                Sprint_Node (Component_List (Node));
2262                Write_Indent_Str ("end record");
2263             end if;
2264
2265          when N_Record_Representation_Clause =>
2266             Write_Indent_Str_Sloc ("for ");
2267             Sprint_Node (Identifier (Node));
2268             Write_Str_With_Col_Check (" use record ");
2269
2270             if Present (Mod_Clause (Node)) then
2271                Sprint_Node (Mod_Clause (Node));
2272             end if;
2273
2274             Sprint_Indented_List (Component_Clauses (Node));
2275             Write_Indent_Str ("end record;");
2276
2277          when N_Reference =>
2278             Sprint_Node (Prefix (Node));
2279             Write_Str_With_Col_Check_Sloc ("'reference");
2280
2281          when N_Requeue_Statement =>
2282             Write_Indent_Str_Sloc ("requeue ");
2283             Sprint_Node (Name (Node));
2284
2285             if Abort_Present (Node) then
2286                Write_Str_With_Col_Check (" with abort");
2287             end if;
2288
2289             Write_Char (';');
2290
2291          when N_Return_Statement =>
2292             if Present (Expression (Node)) then
2293                Write_Indent_Str_Sloc ("return ");
2294                Sprint_Node (Expression (Node));
2295                Write_Char (';');
2296             else
2297                Write_Indent_Str_Sloc ("return;");
2298             end if;
2299
2300          when N_Selective_Accept =>
2301             Write_Indent_Str_Sloc ("select");
2302
2303             declare
2304                Alt_Node : Node_Id;
2305
2306             begin
2307                Alt_Node := First (Select_Alternatives (Node));
2308                loop
2309                   Indent_Begin;
2310                   Sprint_Node (Alt_Node);
2311                   Indent_End;
2312                   Next (Alt_Node);
2313                   exit when No (Alt_Node);
2314                   Write_Indent_Str ("or");
2315                end loop;
2316             end;
2317
2318             if Present (Else_Statements (Node)) then
2319                Write_Indent_Str ("else");
2320                Sprint_Indented_List (Else_Statements (Node));
2321             end if;
2322
2323             Write_Indent_Str ("end select;");
2324
2325          when N_Signed_Integer_Type_Definition =>
2326             Write_Str_With_Col_Check_Sloc ("range ");
2327             Sprint_Node (Low_Bound (Node));
2328             Write_Str (" .. ");
2329             Sprint_Node (High_Bound (Node));
2330
2331          when N_Single_Protected_Declaration =>
2332             Write_Indent_Str_Sloc ("protected ");
2333             Write_Id (Defining_Identifier (Node));
2334             Write_Str (" is");
2335             Sprint_Node (Protected_Definition (Node));
2336             Write_Id (Defining_Identifier (Node));
2337             Write_Char (';');
2338
2339          when N_Single_Task_Declaration =>
2340             Write_Indent_Str_Sloc ("task ");
2341             Write_Id (Defining_Identifier (Node));
2342
2343             if Present (Task_Definition (Node)) then
2344                Write_Str (" is");
2345                Sprint_Node (Task_Definition (Node));
2346                Write_Id (Defining_Identifier (Node));
2347             end if;
2348
2349             Write_Char (';');
2350
2351          when N_Selected_Component =>
2352             Sprint_Node (Prefix (Node));
2353             Write_Char_Sloc ('.');
2354             Sprint_Node (Selector_Name (Node));
2355
2356          when N_Slice =>
2357             Set_Debug_Sloc;
2358             Sprint_Node (Prefix (Node));
2359             Write_Str_With_Col_Check (" (");
2360             Sprint_Node (Discrete_Range (Node));
2361             Write_Char (')');
2362
2363          when N_String_Literal =>
2364             if String_Length (Strval (Node)) + Column > 75 then
2365                Write_Indent_Str ("  ");
2366             end if;
2367
2368             Set_Debug_Sloc;
2369             Write_String_Table_Entry (Strval (Node));
2370
2371          when N_Subprogram_Body =>
2372             if Freeze_Indent = 0 then
2373                Write_Indent;
2374             end if;
2375
2376             Write_Indent;
2377             Sprint_Node_Sloc (Specification (Node));
2378             Write_Str (" is");
2379
2380             Sprint_Indented_List (Declarations (Node));
2381             Write_Indent_Str ("begin");
2382             Sprint_Node (Handled_Statement_Sequence (Node));
2383
2384             Write_Indent_Str ("end ");
2385             Sprint_Node (Defining_Unit_Name (Specification (Node)));
2386             Write_Char (';');
2387
2388             if Is_List_Member (Node)
2389               and then Present (Next (Node))
2390               and then Nkind (Next (Node)) /= N_Subprogram_Body
2391             then
2392                Write_Indent;
2393             end if;
2394
2395          when N_Subprogram_Body_Stub =>
2396             Write_Indent;
2397             Sprint_Node_Sloc (Specification (Node));
2398             Write_Str_With_Col_Check (" is separate;");
2399
2400          when N_Subprogram_Declaration =>
2401             Write_Indent;
2402             Sprint_Node_Sloc (Specification (Node));
2403             Write_Char (';');
2404
2405          when N_Subprogram_Info =>
2406             Sprint_Node (Identifier (Node));
2407             Write_Str_With_Col_Check_Sloc ("'subprogram_info");
2408
2409          when N_Subprogram_Renaming_Declaration =>
2410             Write_Indent;
2411             Sprint_Node (Specification (Node));
2412             Write_Str_With_Col_Check_Sloc (" renames ");
2413             Sprint_Node (Name (Node));
2414             Write_Char (';');
2415
2416          when N_Subtype_Declaration =>
2417             Write_Indent_Str_Sloc ("subtype ");
2418             Write_Id (Defining_Identifier (Node));
2419             Write_Str (" is ");
2420
2421             --  Ada 2005 (AI-231)
2422
2423             if Null_Exclusion_Present (Node) then
2424                Write_Str ("not null ");
2425             end if;
2426
2427             Sprint_Node (Subtype_Indication (Node));
2428             Write_Char (';');
2429
2430          when N_Subtype_Indication =>
2431             Sprint_Node_Sloc (Subtype_Mark (Node));
2432             Write_Char (' ');
2433             Sprint_Node (Constraint (Node));
2434
2435          when N_Subunit =>
2436             Write_Indent_Str_Sloc ("separate (");
2437             Sprint_Node (Name (Node));
2438             Write_Char (')');
2439             Write_Eol;
2440             Sprint_Node (Proper_Body (Node));
2441
2442          when N_Task_Body =>
2443             Write_Indent_Str_Sloc ("task body ");
2444             Write_Id (Defining_Identifier (Node));
2445             Write_Str (" is");
2446             Sprint_Indented_List (Declarations (Node));
2447             Write_Indent_Str ("begin");
2448             Sprint_Node (Handled_Statement_Sequence (Node));
2449             Write_Indent_Str ("end ");
2450             Write_Id (Defining_Identifier (Node));
2451             Write_Char (';');
2452
2453          when N_Task_Body_Stub =>
2454             Write_Indent_Str_Sloc ("task body ");
2455             Write_Id (Defining_Identifier (Node));
2456             Write_Str_With_Col_Check (" is separate;");
2457
2458          when N_Task_Definition =>
2459             Set_Debug_Sloc;
2460             Sprint_Indented_List (Visible_Declarations (Node));
2461
2462             if Present (Private_Declarations (Node)) then
2463                Write_Indent_Str ("private");
2464                Sprint_Indented_List (Private_Declarations (Node));
2465             end if;
2466
2467             Write_Indent_Str ("end ");
2468
2469          when N_Task_Type_Declaration =>
2470             Write_Indent_Str_Sloc ("task type ");
2471             Write_Id (Defining_Identifier (Node));
2472             Write_Discr_Specs (Node);
2473
2474             if Present (Task_Definition (Node)) then
2475                Write_Str (" is");
2476                Sprint_Node (Task_Definition (Node));
2477                Write_Id (Defining_Identifier (Node));
2478             end if;
2479
2480             Write_Char (';');
2481
2482          when N_Terminate_Alternative =>
2483             Sprint_Node_List (Pragmas_Before (Node));
2484
2485             Write_Indent;
2486
2487             if Present (Condition (Node)) then
2488                Write_Str_With_Col_Check ("when ");
2489                Sprint_Node (Condition (Node));
2490                Write_Str (" => ");
2491             end if;
2492
2493             Write_Str_With_Col_Check_Sloc ("terminate;");
2494             Sprint_Node_List (Pragmas_After (Node));
2495
2496          when N_Timed_Entry_Call =>
2497             Write_Indent_Str_Sloc ("select");
2498             Indent_Begin;
2499             Sprint_Node (Entry_Call_Alternative (Node));
2500             Indent_End;
2501             Write_Indent_Str ("or");
2502             Indent_Begin;
2503             Sprint_Node (Delay_Alternative (Node));
2504             Indent_End;
2505             Write_Indent_Str ("end select;");
2506
2507          when N_Triggering_Alternative =>
2508             Sprint_Node_List (Pragmas_Before (Node));
2509             Sprint_Node_Sloc (Triggering_Statement (Node));
2510             Sprint_Node_List (Statements (Node));
2511
2512          when N_Type_Conversion =>
2513             Set_Debug_Sloc;
2514             Sprint_Node (Subtype_Mark (Node));
2515             Col_Check (4);
2516
2517             if Conversion_OK (Node) then
2518                Write_Char ('?');
2519             end if;
2520
2521             if Float_Truncate (Node) then
2522                Write_Char ('^');
2523             end if;
2524
2525             if Rounded_Result (Node) then
2526                Write_Char ('@');
2527             end if;
2528
2529             Write_Char ('(');
2530             Sprint_Node (Expression (Node));
2531             Write_Char (')');
2532
2533          when N_Unchecked_Expression =>
2534             Col_Check (10);
2535             Write_Str ("`(");
2536             Sprint_Node_Sloc (Expression (Node));
2537             Write_Char (')');
2538
2539          when N_Unchecked_Type_Conversion =>
2540             Sprint_Node (Subtype_Mark (Node));
2541             Write_Char ('!');
2542             Write_Str_With_Col_Check ("(");
2543             Sprint_Node_Sloc (Expression (Node));
2544             Write_Char (')');
2545
2546          when N_Unconstrained_Array_Definition =>
2547             Write_Str_With_Col_Check_Sloc ("array (");
2548
2549             declare
2550                Node1 : Node_Id;
2551
2552             begin
2553                Node1 := First (Subtype_Marks (Node));
2554                loop
2555                   Sprint_Node (Node1);
2556                   Write_Str_With_Col_Check (" range <>");
2557                   Next (Node1);
2558                   exit when Node1 = Empty;
2559                   Write_Str (", ");
2560                end loop;
2561             end;
2562
2563             Write_Str (") of ");
2564             Sprint_Node (Component_Definition (Node));
2565
2566          when N_Unused_At_Start | N_Unused_At_End =>
2567             Write_Indent_Str ("***** Error, unused node encountered *****");
2568             Write_Eol;
2569
2570          when N_Use_Package_Clause =>
2571             Write_Indent_Str_Sloc ("use ");
2572             Sprint_Comma_List (Names (Node));
2573             Write_Char (';');
2574
2575          when N_Use_Type_Clause =>
2576             Write_Indent_Str_Sloc ("use type ");
2577             Sprint_Comma_List (Subtype_Marks (Node));
2578             Write_Char (';');
2579
2580          when N_Validate_Unchecked_Conversion =>
2581             Write_Indent_Str_Sloc ("validate unchecked_conversion (");
2582             Sprint_Node (Source_Type (Node));
2583             Write_Str (", ");
2584             Sprint_Node (Target_Type (Node));
2585             Write_Str (");");
2586
2587          when N_Variant =>
2588             Write_Indent_Str_Sloc ("when ");
2589             Sprint_Bar_List (Discrete_Choices (Node));
2590             Write_Str (" => ");
2591             Sprint_Node (Component_List (Node));
2592
2593          when N_Variant_Part =>
2594             Indent_Begin;
2595             Write_Indent_Str_Sloc ("case ");
2596             Sprint_Node (Name (Node));
2597             Write_Str (" is ");
2598             Sprint_Indented_List (Variants (Node));
2599             Write_Indent_Str ("end case");
2600             Indent_End;
2601
2602          when N_With_Clause =>
2603
2604             --  Special test, if we are dumping the original tree only,
2605             --  then we want to eliminate the bogus with clauses that
2606             --  correspond to the non-existent children of Text_IO.
2607
2608             if Dump_Original_Only
2609               and then Is_Text_IO_Kludge_Unit (Name (Node))
2610             then
2611                null;
2612
2613             --  Normal case, output the with clause
2614
2615             else
2616                if First_Name (Node) or else not Dump_Original_Only then
2617
2618                   --  Ada 2005 (AI-50217): Print limited with_clauses
2619
2620                   if Private_Present (Node) and Limited_Present (Node) then
2621                      Write_Indent_Str ("limited private with ");
2622
2623                   elsif Private_Present (Node) then
2624                      Write_Indent_Str ("private with ");
2625
2626                   elsif Limited_Present (Node) then
2627                      Write_Indent_Str ("limited with ");
2628
2629                   else
2630                      Write_Indent_Str ("with ");
2631                   end if;
2632
2633                else
2634                   Write_Str (", ");
2635                end if;
2636
2637                Sprint_Node_Sloc (Name (Node));
2638
2639                if Last_Name (Node) or else not Dump_Original_Only then
2640                   Write_Char (';');
2641                end if;
2642             end if;
2643
2644          when N_With_Type_Clause =>
2645             Write_Indent_Str ("with type ");
2646             Sprint_Node_Sloc (Name (Node));
2647
2648             if Tagged_Present (Node) then
2649                Write_Str (" is tagged;");
2650             else
2651                Write_Str (" is access;");
2652             end if;
2653
2654       end case;
2655
2656       if Nkind (Node) in N_Subexpr
2657         and then Do_Range_Check (Node)
2658       then
2659          Write_Str ("}");
2660       end if;
2661
2662       for J in 1 .. Paren_Count (Node) loop
2663          Write_Char (')');
2664       end loop;
2665
2666       pragma Assert (No (Debug_Node));
2667       Debug_Node := Save_Debug_Node;
2668    end Sprint_Node_Actual;
2669
2670    ----------------------
2671    -- Sprint_Node_List --
2672    ----------------------
2673
2674    procedure Sprint_Node_List (List : List_Id) is
2675       Node : Node_Id;
2676
2677    begin
2678       if Is_Non_Empty_List (List) then
2679          Node := First (List);
2680
2681          loop
2682             Sprint_Node (Node);
2683             Next (Node);
2684             exit when Node = Empty;
2685          end loop;
2686       end if;
2687    end Sprint_Node_List;
2688
2689    ----------------------
2690    -- Sprint_Node_Sloc --
2691    ----------------------
2692
2693    procedure Sprint_Node_Sloc (Node : Node_Id) is
2694    begin
2695       Sprint_Node (Node);
2696
2697       if Present (Debug_Node) then
2698          Set_Sloc (Debug_Node, Sloc (Node));
2699          Debug_Node := Empty;
2700       end if;
2701    end Sprint_Node_Sloc;
2702
2703    ---------------------
2704    -- Sprint_Opt_Node --
2705    ---------------------
2706
2707    procedure Sprint_Opt_Node (Node : Node_Id) is
2708    begin
2709       if Present (Node) then
2710          Write_Char (' ');
2711          Sprint_Node (Node);
2712       end if;
2713    end Sprint_Opt_Node;
2714
2715    --------------------------
2716    -- Sprint_Opt_Node_List --
2717    --------------------------
2718
2719    procedure Sprint_Opt_Node_List (List : List_Id) is
2720    begin
2721       if Present (List) then
2722          Sprint_Node_List (List);
2723       end if;
2724    end Sprint_Opt_Node_List;
2725
2726    ---------------------------------
2727    -- Sprint_Opt_Paren_Comma_List --
2728    ---------------------------------
2729
2730    procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
2731    begin
2732       if Is_Non_Empty_List (List) then
2733          Write_Char (' ');
2734          Sprint_Paren_Comma_List (List);
2735       end if;
2736    end Sprint_Opt_Paren_Comma_List;
2737
2738    -----------------------------
2739    -- Sprint_Paren_Comma_List --
2740    -----------------------------
2741
2742    procedure Sprint_Paren_Comma_List (List : List_Id) is
2743       N           : Node_Id;
2744       Node_Exists : Boolean := False;
2745
2746    begin
2747
2748       if Is_Non_Empty_List (List) then
2749
2750          if Dump_Original_Only then
2751             N := First (List);
2752
2753             while Present (N) loop
2754
2755                if not Is_Rewrite_Insertion (N) then
2756                   Node_Exists := True;
2757                   exit;
2758                end if;
2759
2760                Next (N);
2761             end loop;
2762
2763             if not Node_Exists then
2764                return;
2765             end if;
2766          end if;
2767
2768          Write_Str_With_Col_Check ("(");
2769          Sprint_Comma_List (List);
2770          Write_Char (')');
2771       end if;
2772    end Sprint_Paren_Comma_List;
2773
2774    ----------------------
2775    -- Sprint_Right_Opnd --
2776    ----------------------
2777
2778    procedure Sprint_Right_Opnd (N : Node_Id) is
2779       Opnd : constant Node_Id := Right_Opnd (N);
2780
2781    begin
2782       if Paren_Count (Opnd) /= 0
2783         or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N))
2784       then
2785          Sprint_Node (Opnd);
2786
2787       else
2788          Write_Char ('(');
2789          Sprint_Node (Opnd);
2790          Write_Char (')');
2791       end if;
2792    end Sprint_Right_Opnd;
2793
2794    ---------------------
2795    -- Write_Char_Sloc --
2796    ---------------------
2797
2798    procedure Write_Char_Sloc (C : Character) is
2799    begin
2800       if Debug_Generated_Code and then C /= ' ' then
2801          Set_Debug_Sloc;
2802       end if;
2803
2804       Write_Char (C);
2805    end Write_Char_Sloc;
2806
2807    --------------------------------
2808    -- Write_Condition_And_Reason --
2809    --------------------------------
2810
2811    procedure Write_Condition_And_Reason (Node : Node_Id) is
2812       Image : constant String := RT_Exception_Code'Image
2813                                    (RT_Exception_Code'Val
2814                                      (UI_To_Int (Reason (Node))));
2815
2816    begin
2817       if Present (Condition (Node)) then
2818          Write_Str_With_Col_Check (" when ");
2819          Sprint_Node (Condition (Node));
2820       end if;
2821
2822       Write_Str (" """);
2823
2824       for J in 4 .. Image'Last loop
2825          if Image (J) = '_' then
2826             Write_Char (' ');
2827          else
2828             Write_Char (Fold_Lower (Image (J)));
2829          end if;
2830       end loop;
2831
2832       Write_Str ("""]");
2833    end Write_Condition_And_Reason;
2834
2835    -----------------------
2836    -- Write_Discr_Specs --
2837    -----------------------
2838
2839    procedure Write_Discr_Specs (N : Node_Id) is
2840       Specs : List_Id;
2841       Spec  : Node_Id;
2842
2843    begin
2844       Specs := Discriminant_Specifications (N);
2845
2846       if Present (Specs) then
2847          Write_Str_With_Col_Check (" (");
2848          Spec := First (Specs);
2849
2850          loop
2851             Sprint_Node (Spec);
2852             Next (Spec);
2853             exit when Spec = Empty;
2854
2855             --  Add semicolon, unless we are printing original tree and the
2856             --  next specification is part of a list (but not the first
2857             --  element of that list)
2858
2859             if not Dump_Original_Only or else not Prev_Ids (Spec) then
2860                Write_Str ("; ");
2861             end if;
2862          end loop;
2863
2864          Write_Char (')');
2865       end if;
2866    end Write_Discr_Specs;
2867
2868    -----------------
2869    -- Write_Ekind --
2870    -----------------
2871
2872    procedure Write_Ekind (E : Entity_Id) is
2873       S : constant String := Entity_Kind'Image (Ekind (E));
2874
2875    begin
2876       Name_Len := S'Length;
2877       Name_Buffer (1 .. Name_Len) := S;
2878       Set_Casing (Mixed_Case);
2879       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2880    end Write_Ekind;
2881
2882    --------------
2883    -- Write_Id --
2884    --------------
2885
2886    procedure Write_Id (N : Node_Id) is
2887    begin
2888       --  Case of a defining identifier
2889
2890       if Nkind (N) = N_Defining_Identifier then
2891
2892          --  If defining identifier has an interface name (and no
2893          --  address clause), then we output the interface name.
2894
2895          if (Is_Imported (N) or else Is_Exported (N))
2896            and then Present (Interface_Name (N))
2897            and then No (Address_Clause (N))
2898          then
2899             String_To_Name_Buffer (Strval (Interface_Name (N)));
2900             Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
2901
2902          --  If no interface name (or inactive because there was
2903          --  an address clause), then just output the Chars name.
2904
2905          else
2906             Write_Name_With_Col_Check (Chars (N));
2907          end if;
2908
2909       --  Case of selector of an expanded name where the expanded name
2910       --  has an associated entity, output this entity.
2911
2912       elsif Nkind (Parent (N)) = N_Expanded_Name
2913         and then Selector_Name (Parent (N)) = N
2914         and then Present (Entity (Parent (N)))
2915       then
2916          Write_Id (Entity (Parent (N)));
2917
2918       --  For any other node with an associated entity, output it
2919
2920       elsif Nkind (N) in N_Has_Entity
2921         and then Present (Entity_Or_Associated_Node (N))
2922         and then Nkind (Entity_Or_Associated_Node (N)) in N_Entity
2923       then
2924          Write_Id (Entity (N));
2925
2926       --  All other cases, we just print the Chars field
2927
2928       else
2929          Write_Name_With_Col_Check (Chars (N));
2930       end if;
2931    end Write_Id;
2932
2933    -----------------------
2934    -- Write_Identifiers --
2935    -----------------------
2936
2937    function Write_Identifiers (Node : Node_Id) return Boolean is
2938    begin
2939       Sprint_Node (Defining_Identifier (Node));
2940
2941       --  The remainder of the declaration must be printed unless we are
2942       --  printing the original tree and this is not the last identifier
2943
2944       return
2945          not Dump_Original_Only or else not More_Ids (Node);
2946
2947    end Write_Identifiers;
2948
2949    ------------------------
2950    -- Write_Implicit_Def --
2951    ------------------------
2952
2953    procedure Write_Implicit_Def (E : Entity_Id) is
2954       Ind : Node_Id;
2955
2956    begin
2957       case Ekind (E) is
2958          when E_Array_Subtype =>
2959             Write_Str_With_Col_Check ("subtype ");
2960             Write_Id (E);
2961             Write_Str_With_Col_Check (" is ");
2962             Write_Id (Base_Type (E));
2963             Write_Str_With_Col_Check (" (");
2964
2965             Ind := First_Index (E);
2966
2967             while Present (Ind) loop
2968                Sprint_Node (Ind);
2969                Next_Index (Ind);
2970
2971                if Present (Ind) then
2972                   Write_Str (", ");
2973                end if;
2974             end loop;
2975
2976             Write_Str (");");
2977
2978          when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
2979             Write_Str_With_Col_Check ("subtype ");
2980             Write_Id (E);
2981             Write_Str (" is ");
2982             Write_Id (Etype (E));
2983             Write_Str_With_Col_Check (" range ");
2984             Sprint_Node (Scalar_Range (E));
2985             Write_Str (";");
2986
2987          when others =>
2988             Write_Str_With_Col_Check ("type ");
2989             Write_Id (E);
2990             Write_Str_With_Col_Check (" is <");
2991             Write_Ekind (E);
2992             Write_Str (">;");
2993       end case;
2994
2995    end Write_Implicit_Def;
2996
2997    ------------------
2998    -- Write_Indent --
2999    ------------------
3000
3001    procedure Write_Indent is
3002    begin
3003       if Indent_Annull_Flag then
3004          Indent_Annull_Flag := False;
3005       else
3006          Write_Eol;
3007
3008          for J in 1 .. Indent loop
3009             Write_Char (' ');
3010          end loop;
3011       end if;
3012    end Write_Indent;
3013
3014    ------------------------------
3015    -- Write_Indent_Identifiers --
3016    ------------------------------
3017
3018    function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
3019    begin
3020       --  We need to start a new line for every node, except in the case
3021       --  where we are printing the original tree and this is not the first
3022       --  defining identifier in the list.
3023
3024       if not Dump_Original_Only or else not Prev_Ids (Node) then
3025          Write_Indent;
3026
3027       --  If printing original tree and this is not the first defining
3028       --  identifier in the list, then the previous call to this procedure
3029       --  printed only the name, and we add a comma to separate the names.
3030
3031       else
3032          Write_Str (", ");
3033       end if;
3034
3035       Sprint_Node (Defining_Identifier (Node));
3036
3037       --  The remainder of the declaration must be printed unless we are
3038       --  printing the original tree and this is not the last identifier
3039
3040       return
3041          not Dump_Original_Only or else not More_Ids (Node);
3042
3043    end Write_Indent_Identifiers;
3044
3045    -----------------------------------
3046    -- Write_Indent_Identifiers_Sloc --
3047    -----------------------------------
3048
3049    function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
3050    begin
3051       --  We need to start a new line for every node, except in the case
3052       --  where we are printing the original tree and this is not the first
3053       --  defining identifier in the list.
3054
3055       if not Dump_Original_Only or else not Prev_Ids (Node) then
3056          Write_Indent;
3057
3058       --  If printing original tree and this is not the first defining
3059       --  identifier in the list, then the previous call to this procedure
3060       --  printed only the name, and we add a comma to separate the names.
3061
3062       else
3063          Write_Str (", ");
3064       end if;
3065
3066       Set_Debug_Sloc;
3067       Sprint_Node (Defining_Identifier (Node));
3068
3069       --  The remainder of the declaration must be printed unless we are
3070       --  printing the original tree and this is not the last identifier
3071
3072       return
3073          not Dump_Original_Only or else not More_Ids (Node);
3074
3075    end Write_Indent_Identifiers_Sloc;
3076
3077    ----------------------
3078    -- Write_Indent_Str --
3079    ----------------------
3080
3081    procedure Write_Indent_Str (S : String) is
3082    begin
3083       Write_Indent;
3084       Write_Str (S);
3085    end Write_Indent_Str;
3086
3087    ---------------------------
3088    -- Write_Indent_Str_Sloc --
3089    ---------------------------
3090
3091    procedure Write_Indent_Str_Sloc (S : String) is
3092    begin
3093       Write_Indent;
3094       Write_Str_Sloc (S);
3095    end Write_Indent_Str_Sloc;
3096
3097    -------------------------------
3098    -- Write_Name_With_Col_Check --
3099    -------------------------------
3100
3101    procedure Write_Name_With_Col_Check (N : Name_Id) is
3102       J : Natural;
3103
3104    begin
3105       Get_Name_String (N);
3106
3107       --  Deal with -gnatI which replaces digits in an internal
3108       --  name by three dots (e.g. R7b becomes R...b).
3109
3110       if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
3111
3112          J := 2;
3113          while J < Name_Len loop
3114             exit when Name_Buffer (J) not in 'A' .. 'Z';
3115             J := J + 1;
3116          end loop;
3117
3118          if Name_Buffer (J) in '0' .. '9' then
3119             Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
3120             Write_Str ("...");
3121
3122             while J <= Name_Len loop
3123                if Name_Buffer (J) not in '0' .. '9' then
3124                   Write_Str (Name_Buffer (J .. Name_Len));
3125                   exit;
3126
3127                else
3128                   J := J + 1;
3129                end if;
3130             end loop;
3131
3132             return;
3133          end if;
3134       end if;
3135
3136       --  Fall through for normal case
3137
3138       Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
3139    end Write_Name_With_Col_Check;
3140
3141    ------------------------------------
3142    -- Write_Name_With_Col_Check_Sloc --
3143    ------------------------------------
3144
3145    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
3146    begin
3147       Get_Name_String (N);
3148       Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
3149    end Write_Name_With_Col_Check_Sloc;
3150
3151    --------------------
3152    -- Write_Operator --
3153    --------------------
3154
3155    procedure Write_Operator (N : Node_Id; S : String) is
3156       F : Natural := S'First;
3157       T : Natural := S'Last;
3158
3159    begin
3160       --  If no overflow check, just write string out, and we are done
3161
3162       if not Do_Overflow_Check (N) then
3163          Write_Str_Sloc (S);
3164
3165       --  If overflow check, we want to surround the operator with curly
3166       --  brackets, but not include spaces within the brackets.
3167
3168       else
3169          if S (F) = ' ' then
3170             Write_Char (' ');
3171             F := F + 1;
3172          end if;
3173
3174          if S (T) = ' ' then
3175             T := T - 1;
3176          end if;
3177
3178          Write_Char ('{');
3179          Write_Str_Sloc (S (F .. T));
3180          Write_Char ('}');
3181
3182          if S (S'Last) = ' ' then
3183             Write_Char (' ');
3184          end if;
3185       end if;
3186    end Write_Operator;
3187
3188    -----------------------
3189    -- Write_Param_Specs --
3190    -----------------------
3191
3192    procedure Write_Param_Specs (N : Node_Id) is
3193       Specs  : List_Id;
3194       Spec   : Node_Id;
3195       Formal : Node_Id;
3196
3197    begin
3198       Specs := Parameter_Specifications (N);
3199
3200       if Is_Non_Empty_List (Specs) then
3201          Write_Str_With_Col_Check (" (");
3202          Spec := First (Specs);
3203
3204          loop
3205             Sprint_Node (Spec);
3206             Formal := Defining_Identifier (Spec);
3207             Next (Spec);
3208             exit when Spec = Empty;
3209
3210             --  Add semicolon, unless we are printing original tree and the
3211             --  next specification is part of a list (but not the first
3212             --  element of that list)
3213
3214             if not Dump_Original_Only or else not Prev_Ids (Spec) then
3215                Write_Str ("; ");
3216             end if;
3217          end loop;
3218
3219          --  Write out any extra formals
3220
3221          while Present (Extra_Formal (Formal)) loop
3222             Formal := Extra_Formal (Formal);
3223             Write_Str ("; ");
3224             Write_Name_With_Col_Check (Chars (Formal));
3225             Write_Str (" : ");
3226             Write_Name_With_Col_Check (Chars (Etype (Formal)));
3227          end loop;
3228
3229          Write_Char (')');
3230       end if;
3231    end Write_Param_Specs;
3232
3233    --------------------------
3234    -- Write_Rewrite_Str --
3235    --------------------------
3236
3237    procedure Write_Rewrite_Str (S : String) is
3238    begin
3239       if not Dump_Generated_Only then
3240          if S'Length = 3 and then S = ">>>" then
3241             Write_Str (">>>");
3242          else
3243             Write_Str_With_Col_Check (S);
3244          end if;
3245       end if;
3246    end Write_Rewrite_Str;
3247
3248    --------------------
3249    -- Write_Str_Sloc --
3250    --------------------
3251
3252    procedure Write_Str_Sloc (S : String) is
3253    begin
3254       for J in S'Range loop
3255          Write_Char_Sloc (S (J));
3256       end loop;
3257    end Write_Str_Sloc;
3258
3259    ------------------------------
3260    -- Write_Str_With_Col_Check --
3261    ------------------------------
3262
3263    procedure Write_Str_With_Col_Check (S : String) is
3264    begin
3265       if Int (S'Last) + Column > Line_Limit then
3266          Write_Indent_Str ("  ");
3267
3268          if S (1) = ' ' then
3269             Write_Str (S (2 .. S'Length));
3270          else
3271             Write_Str (S);
3272          end if;
3273
3274       else
3275          Write_Str (S);
3276       end if;
3277    end Write_Str_With_Col_Check;
3278
3279    -----------------------------------
3280    -- Write_Str_With_Col_Check_Sloc --
3281    -----------------------------------
3282
3283    procedure Write_Str_With_Col_Check_Sloc (S : String) is
3284    begin
3285       if Int (S'Last) + Column > Line_Limit then
3286          Write_Indent_Str ("  ");
3287
3288          if S (1) = ' ' then
3289             Write_Str_Sloc (S (2 .. S'Length));
3290          else
3291             Write_Str_Sloc (S);
3292          end if;
3293
3294       else
3295          Write_Str_Sloc (S);
3296       end if;
3297    end Write_Str_With_Col_Check_Sloc;
3298
3299    ------------------------------------
3300    -- Write_Uint_With_Col_Check_Sloc --
3301    ------------------------------------
3302
3303    procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
3304    begin
3305       Col_Check (UI_Decimal_Digits_Hi (U));
3306       Set_Debug_Sloc;
3307       UI_Write (U, Format);
3308    end Write_Uint_With_Col_Check_Sloc;
3309
3310    -------------------------------------
3311    -- Write_Ureal_With_Col_Check_Sloc --
3312    -------------------------------------
3313
3314    procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
3315       D : constant Uint := Denominator (U);
3316       N : constant Uint := Numerator (U);
3317
3318    begin
3319       Col_Check
3320         (UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
3321       Set_Debug_Sloc;
3322       UR_Write (U);
3323    end Write_Ureal_With_Col_Check_Sloc;
3324
3325 end Sprint;