OSDN Git Service

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