~ubuntu-branches/ubuntu/hardy/asis/hardy-proposed

« back to all changes in this revision

Viewing changes to tools/gnatpp/gnatpp-pp_output.adb

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Brenta
  • Date: 2006-08-08 23:02:17 UTC
  • mfrom: (3.1.6 edgy)
  • Revision ID: james.westby@ubuntu.com-20060808230217-8j3ts1m8i83e0apm
Tags: 2005-5

debian/control: add support for alpha and s390.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
------------------------------------------------------------------------------
 
2
--                                                                          --
 
3
--                            GNATPP COMPONENTS                             --
 
4
--                                                                          --
 
5
--                     G N A T P P . P P _ O U T P U T                      --
 
6
--                                                                          --
 
7
--                                 B o d y                                  --
 
8
--                                                                          --
 
9
--                   Copyright (C) 2001-2004, ACT Europe                    --
 
10
--                                                                          --
 
11
-- GNATPP 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.  GNATPP is  distributed in the  hope that it will  be  useful, but --
 
15
-- WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABI- --
 
16
-- LITY or  FITNESS  FOR A  PARTICULAR  PURPOSE. See the GNU General Public --
 
17
-- License  for more details. You  should  have  received a copy of the GNU --
 
18
-- General Public License  distributed with GNAT; see file COPYING. If not, --
 
19
-- write  to  the Free  Software  Foundation,  59 Temple Place - Suite 330, --
 
20
-- Boston,                                                                  --
 
21
--                                                                          --
 
22
-- GNATPP is maintained by ACT Europe (http://www.act-europe.fr).           --
 
23
--                                                                          --
 
24
------------------------------------------------------------------------------
 
25
 
 
26
with Ada.Wide_Text_IO;                use Ada.Wide_Text_IO;
 
27
with Ada.Characters.Handling;         use Ada.Characters.Handling;
 
28
 
 
29
with GNATPP.Source_Line_Buffer;       use GNATPP.Source_Line_Buffer;
 
30
with GNATPP.Output;                   use GNATPP.Output;
 
31
with GNATPP.State;                    use GNATPP.State;
 
32
with GNATPP.Paragraphs;               use GNATPP.Paragraphs;
 
33
 
 
34
package body GNATPP.PP_Output is
 
35
 
 
36
   Last_Char_Was_Space : Boolean := False;
 
37
 
 
38
   -------------------------
 
39
   -- Available_In_Output --
 
40
   -------------------------
 
41
 
 
42
   function Available_In_Output return Integer is
 
43
      Result : Integer := Max_Line_Length - Output_Pos + 1;
 
44
   begin
 
45
      if Postponed_Space then
 
46
         Result := Result - 1;
 
47
      end if;
 
48
 
 
49
      return Result;
 
50
   end Available_In_Output;
 
51
 
 
52
   --------------------
 
53
   -- Get_Output_Pos --
 
54
   --------------------
 
55
 
 
56
   function Get_Output_Pos return Integer is
 
57
      Result : Integer := Output_Pos;
 
58
   begin
 
59
 
 
60
      if Postponed_Space then
 
61
         Result := Result + 1;
 
62
      end if;
 
63
 
 
64
      return Result;
 
65
   end Get_Output_Pos;
 
66
 
 
67
   -------------------
 
68
   -- PP_Close_Line --
 
69
   -------------------
 
70
 
 
71
   procedure PP_Close_Line is
 
72
   begin
 
73
 
 
74
      if The_Very_First_Line then
 
75
         The_Very_First_Line := False;
 
76
      end if;
 
77
 
 
78
      New_Line;
 
79
 
 
80
      Current_Out_Line    := Current_Out_Line + 1;
 
81
      Is_New_Output_Line  := True;
 
82
      Output_Pos          := 1;
 
83
      Output_Line         := Output_Line + 1;
 
84
      Last_Char_Was_Space := False;
 
85
   end PP_Close_Line;
 
86
 
 
87
   ----------------------
 
88
   -- PP_Continue_Line --
 
89
   ----------------------
 
90
 
 
91
   procedure PP_Continue_Line (Adjust_New_Line_Depth : Integer := 0) is
 
92
   begin
 
93
      Saved_Last_KW  := Last_KW;
 
94
      Saved_Last_Dlm := Last_Dlm;
 
95
 
 
96
      if Is_New_Output_Line then
 
97
 
 
98
         PP_New_Continuation_Line (Adjust_New_Line_Depth);
 
99
         Last_Char_Was_Space := True;
 
100
 
 
101
      elsif not Last_Char_Was_Space and then
 
102
            Output_Pos < Max_Line_Length
 
103
      then
 
104
         PP_Word_No_Move (" ");
 
105
         Last_Char_Was_Space := True;
 
106
         Postponed_Space := False;
 
107
      end if;
 
108
 
 
109
      Last_KW  := Saved_Last_KW;
 
110
      Last_Dlm := Saved_Last_Dlm;
 
111
   end PP_Continue_Line;
 
112
 
 
113
   --------------------------------
 
114
   -- PP_Continue_Line_Postponed --
 
115
   --------------------------------
 
116
 
 
117
   procedure PP_Continue_Line_Postponed
 
118
     (Adjust_New_Line_Depth : Integer := 0)
 
119
   is
 
120
   begin
 
121
      Saved_Last_KW  := Last_KW;
 
122
      Saved_Last_Dlm := Last_Dlm;
 
123
 
 
124
      if Is_New_Output_Line then
 
125
         PP_New_Line
 
126
           (Adjust_Depth => Adjust_New_Line_Depth + 1,
 
127
            Backspace    => 1);
 
128
         Last_Char_Was_Space := True;
 
129
 
 
130
      elsif not Last_Char_Was_Space and then
 
131
            Output_Pos < Max_Line_Length
 
132
      then
 
133
         Postponed_Space := True;
 
134
      end if;
 
135
 
 
136
      Last_KW  := Saved_Last_KW;
 
137
      Last_Dlm := Saved_Last_Dlm;
 
138
   end PP_Continue_Line_Postponed;
 
139
 
 
140
   ------------------
 
141
   -- PP_Delimiter --
 
142
   ------------------
 
143
 
 
144
   procedure PP_Delimiter (DL : Delimiter_Kinds) is
 
145
   begin
 
146
 
 
147
      case DL is
 
148
         when Not_A_Dlm               => null;
 
149
         when Ampersand_Dlm           => PP_Word ("&");
 
150
         when Tick_Dlm                => PP_Word ("'");
 
151
         when Left_Parenthesis_Dlm    => PP_Word ("(");
 
152
         when Right_Parenthesis_Dlm   => PP_Word (")");
 
153
         when Asterisk_Dlm            => PP_Word ("*");
 
154
         when Plus_Dlm                => PP_Word ("+");
 
155
         when Comma_Dlm               => PP_Word (",");
 
156
         when Minus_Dlm               => PP_Word ("-");
 
157
         when Dot_Dlm                 => PP_Word (".");
 
158
         when Divide_Dlm              => PP_Word ("/");
 
159
         when Colon_Dlm               => PP_Word (":");
 
160
         when Semicolon_Dlm           => PP_Word (";");
 
161
         when Less_Than_Dlm           => PP_Word ("<");
 
162
         when Equals_Dlm              => PP_Word ("=");
 
163
         when Greater_Than_Dlm        => PP_Word (">");
 
164
         when Vertical_Line_Dlm       => PP_Word ("|");
 
165
         when Exclamation_Mark_Dlm    => PP_Word ("!");
 
166
         when Arrow_Dlm               => PP_Word ("=>");
 
167
         when Double_Dot_Dlm          => PP_Word ("..");
 
168
         when Double_Star_Dlm         => PP_Word ("**");
 
169
         when Assignment_Dlm          => PP_Word (":=");
 
170
         when Inequality_Dlm          => PP_Word ("/=");
 
171
         when Greater_Or_Equal_Dlm    => PP_Word (">=");
 
172
         when Less_Or_Equal_Dlm       => PP_Word ("<=");
 
173
         when Left_Label_Bracket_Dlm  => PP_Word ("<<");
 
174
         when Right_Label_Bracket_Dlm => PP_Word (">>");
 
175
         when Box_Dlm                 => PP_Word ("<>");
 
176
      end case;
 
177
 
 
178
      Last_KW  := Not_A_KW;
 
179
      Last_Dlm := DL;
 
180
 
 
181
      if DL /= Not_A_Dlm then
 
182
         Last_Char_Was_Space := False;
 
183
      end if;
 
184
 
 
185
   end PP_Delimiter;
 
186
 
 
187
   ----------------
 
188
   -- PP_Keyword --
 
189
   ----------------
 
190
 
 
191
   procedure PP_Keyword (KW : Keyword_Kinds) is
 
192
      function Adjust_KW_Case (Str : Program_Text) return Program_Text;
 
193
      --  Converts the keyword casing according to the gnatpp settings
 
194
 
 
195
      function Adjust_KW_Case (Str : Program_Text) return Program_Text is
 
196
         Result : Program_Text := Str;
 
197
      begin
 
198
 
 
199
         if GNATPP.Options.PP_Keyword_Casing = Upper_Case then
 
200
            Result := To_Wide_String (To_Upper (To_String (Result)));
 
201
         end if;
 
202
 
 
203
         return Result;
 
204
 
 
205
      end Adjust_KW_Case;
 
206
 
 
207
   begin
 
208
 
 
209
      case KW is
 
210
 
 
211
         when Not_A_KW     => null;
 
212
         when KW_Abort     => PP_Word (Adjust_KW_Case (Abort_String));
 
213
         when KW_Abs       => PP_Word (Adjust_KW_Case (Abs_String));
 
214
         when KW_Abstract  => PP_Word (Adjust_KW_Case (Abstract_String));
 
215
         when KW_Accept    => PP_Word (Adjust_KW_Case (Accept_String));
 
216
         when KW_Access    => PP_Word (Adjust_KW_Case (Access_String));
 
217
         when KW_Aliased   => PP_Word (Adjust_KW_Case (Aliased_String));
 
218
         when KW_All       => PP_Word (Adjust_KW_Case (All_String));
 
219
         when KW_And       => PP_Word (Adjust_KW_Case (And_String));
 
220
         when KW_Array     => PP_Word (Adjust_KW_Case (Array_String));
 
221
         when KW_At        => PP_Word (Adjust_KW_Case (At_String));
 
222
 
 
223
         when KW_Begin     =>
 
224
            PP_Word (Adjust_KW_Case (Begin_String));
 
225
            Set_No_Paragraph;
 
226
 
 
227
         when KW_Body      => PP_Word (Adjust_KW_Case (Body_String));
 
228
         when KW_Case      => PP_Word (Adjust_KW_Case (Case_String));
 
229
         when KW_Constant  => PP_Word (Adjust_KW_Case (Constant_String));
 
230
         when KW_Declare   => PP_Word (Adjust_KW_Case (Declare_String));
 
231
         when KW_Delay     => PP_Word (Adjust_KW_Case (Delay_String));
 
232
         when KW_Delta     => PP_Word (Adjust_KW_Case (Delta_String));
 
233
         when KW_Digits    => PP_Word (Adjust_KW_Case (Digits_String));
 
234
         when KW_Do        => PP_Word (Adjust_KW_Case (Do_String));
 
235
         when KW_Else      => PP_Word (Adjust_KW_Case (Else_String));
 
236
 
 
237
         when KW_Elsif     =>
 
238
            PP_Word (Adjust_KW_Case (Elsif_String));
 
239
            Last_If_Path_Start := Current_Out_Line;
 
240
 
 
241
         when KW_End       => PP_Word (Adjust_KW_Case (End_String));
 
242
         when KW_Entry     => PP_Word (Adjust_KW_Case (Entry_String));
 
243
         when KW_Exception => PP_Word (Adjust_KW_Case (Exception_String));
 
244
         when KW_Exit      => PP_Word (Adjust_KW_Case (Exit_String));
 
245
 
 
246
         when KW_For       =>
 
247
            PP_Word (Adjust_KW_Case (For_String));
 
248
            Last_Loop_Start := Current_Out_Line;
 
249
 
 
250
         when KW_Function  => PP_Word (Adjust_KW_Case (Function_String));
 
251
         when KW_Generic   => PP_Word (Adjust_KW_Case (Generic_String));
 
252
         when KW_Goto      => PP_Word (Adjust_KW_Case (Goto_String));
 
253
 
 
254
         when KW_If        =>
 
255
            PP_Word (Adjust_KW_Case (If_String));
 
256
            Last_If_Path_Start := Current_Out_Line;
 
257
 
 
258
         when KW_In        => PP_Word (Adjust_KW_Case (In_String));
 
259
         when KW_Is        => PP_Word (Adjust_KW_Case (KW_Is_String));
 
260
         when KW_Limited   => PP_Word (Adjust_KW_Case (Limited_String));
 
261
         when KW_Loop      => PP_Word (Adjust_KW_Case (Loop_String));
 
262
         when KW_Mod       => PP_Word (Adjust_KW_Case (Mod_String));
 
263
         when KW_New       => PP_Word (Adjust_KW_Case (New_String));
 
264
         when KW_Not       => PP_Word (Adjust_KW_Case (Not_String));
 
265
         when KW_Null      => PP_Word (Adjust_KW_Case (Null_String));
 
266
         when KW_Of        => PP_Word (Adjust_KW_Case (Of_String));
 
267
         when KW_Or        => PP_Word (Adjust_KW_Case (Or_String));
 
268
         when KW_Others    => PP_Word (Adjust_KW_Case (Others_String));
 
269
         when KW_Out       => PP_Word (Adjust_KW_Case (Out_String));
 
270
         when KW_Package   => PP_Word (Adjust_KW_Case (Package_String));
 
271
         when KW_Pragma    => PP_Word (Adjust_KW_Case (Pragma_String));
 
272
 
 
273
         when KW_Private   =>
 
274
            PP_Word (Adjust_KW_Case (Private_String));
 
275
            Set_No_Paragraph;
 
276
 
 
277
         when KW_Procedure => PP_Word (Adjust_KW_Case (Procedure_String));
 
278
         when KW_Protected => PP_Word (Adjust_KW_Case (Protected_String));
 
279
         when KW_Raise     => PP_Word (Adjust_KW_Case (Raise_String));
 
280
         when KW_Range     => PP_Word (Adjust_KW_Case (Range_String));
 
281
         when KW_Record    => PP_Word (Adjust_KW_Case (Record_String));
 
282
         when KW_Rem       => PP_Word (Adjust_KW_Case (Rem_String));
 
283
         when KW_Renames   => PP_Word (Adjust_KW_Case (Renames_String));
 
284
         when KW_Requeue   => PP_Word (Adjust_KW_Case (Requeue_String));
 
285
         when KW_Return    => PP_Word (Adjust_KW_Case (Return_String));
 
286
         when KW_Reverse   => PP_Word (Adjust_KW_Case (Reverse_String));
 
287
         when KW_Select    => PP_Word (Adjust_KW_Case (Select_String));
 
288
         when KW_Separate  => PP_Word (Adjust_KW_Case (Separate_String));
 
289
         when KW_Subtype   => PP_Word (Adjust_KW_Case (Subtype_String));
 
290
         when KW_Tagged    => PP_Word (Adjust_KW_Case (Tagged_String));
 
291
         when KW_Task      => PP_Word (Adjust_KW_Case (Task_String));
 
292
         when KW_Terminate => PP_Word (Adjust_KW_Case (Terminate_String));
 
293
         when KW_Then      => PP_Word (Adjust_KW_Case (Then_String));
 
294
 
 
295
         when KW_Type      =>
 
296
            PP_Word (Adjust_KW_Case (Type_String));
 
297
            Last_Type_Start := Current_Out_Line;
 
298
 
 
299
         when KW_Until     => PP_Word (Adjust_KW_Case (Until_String));
 
300
         when KW_Use       => PP_Word (Adjust_KW_Case (Use_String));
 
301
         when KW_When      => PP_Word (Adjust_KW_Case (When_String));
 
302
 
 
303
         when KW_While     =>
 
304
            PP_Word (Adjust_KW_Case (While_String));
 
305
            Last_Loop_Start := Current_Out_Line;
 
306
 
 
307
         when KW_With      => PP_Word (Adjust_KW_Case (With_String));
 
308
         when KW_Xor       => PP_Word (Adjust_KW_Case (Xor_String));
 
309
      end case;
 
310
 
 
311
      Last_KW  := KW;
 
312
      Last_Dlm := Not_A_Dlm;
 
313
 
 
314
      if KW /= Not_A_KW then
 
315
         Last_Char_Was_Space := False;
 
316
      end if;
 
317
 
 
318
   end PP_Keyword;
 
319
 
 
320
   ------------------------------
 
321
   -- PP_New_Continuation_Line --
 
322
   ------------------------------
 
323
 
 
324
   procedure PP_New_Continuation_Line (Adjust_New_Line_Depth : Integer := 0) is
 
325
   begin
 
326
      if not Is_New_Output_Line or else
 
327
         Output_Pos = 1
 
328
      then
 
329
         PP_New_Line (Adjust_Depth => Adjust_New_Line_Depth);
 
330
         PP_Pad (PP_Cont_Line_Indentation + 1);
 
331
         Last_Char_Was_Space := True;
 
332
         Postponed_Space := False;
 
333
      end if;
 
334
   end PP_New_Continuation_Line;
 
335
 
 
336
   -----------------
 
337
   -- PP_New_Line --
 
338
   -----------------
 
339
 
 
340
   procedure PP_New_Line
 
341
     (Adjust_Depth : Integer := 0;
 
342
      Backspace    : Natural := 0)
 
343
   is
 
344
      Actual_Indent : Natural;
 
345
   begin
 
346
 
 
347
      if The_Very_First_Line then
 
348
         The_Very_First_Line := False;
 
349
         return;
 
350
      end if;
 
351
 
 
352
      if not Is_New_Output_Line then
 
353
         PP_Close_Line;
 
354
         Last_Char_Was_Space := False;
 
355
      end if;
 
356
 
 
357
      Output_Pos := Integer (Col);
 
358
 
 
359
      if Output_Pos = 1 then
 
360
         Actual_Indent :=
 
361
           (Logical_Depth + Adjust_Depth) * PP_Indentation - Backspace;
 
362
 
 
363
         for J in 1 .. Actual_Indent loop
 
364
            PP_Space;
 
365
         end loop;
 
366
 
 
367
         if Actual_Indent > 0 then
 
368
            Last_Char_Was_Space := True;
 
369
         end if;
 
370
 
 
371
      end if;
 
372
 
 
373
      Postponed_Space := False;
 
374
   end PP_New_Line;
 
375
 
 
376
   -------------------------
 
377
   -- PP_New_Line_And_Pad --
 
378
   -------------------------
 
379
 
 
380
   procedure PP_New_Line_And_Pad (Up_To : Natural := 0) is
 
381
   begin
 
382
 
 
383
      Last_Char_Was_Space := False;
 
384
 
 
385
      if The_Very_First_Line then
 
386
         The_Very_First_Line := False;
 
387
         return;
 
388
      end if;
 
389
 
 
390
      if not Is_New_Output_Line then
 
391
         PP_Close_Line;
 
392
      end if;
 
393
 
 
394
      if Output_Pos = 1 then
 
395
         PP_Pad (Up_To);
 
396
      end if;
 
397
 
 
398
   end PP_New_Line_And_Pad;
 
399
 
 
400
   -------------------------------
 
401
   -- PP_New_Line_For_Index_Def --
 
402
   -------------------------------
 
403
 
 
404
   procedure PP_New_Line_For_Index_Def is
 
405
      Up_To : constant Natural := (Logical_Depth + 1) * PP_Indentation + 6 + 1;
 
406
   begin
 
407
      PP_New_Line_And_Pad (Up_To);
 
408
   end PP_New_Line_For_Index_Def;
 
409
 
 
410
   -----------------
 
411
   -- PP_Operator --
 
412
   -----------------
 
413
 
 
414
   procedure PP_Operator (Op : Flat_Element_Kinds) is
 
415
   begin
 
416
      Last_KW  := Not_A_KW;
 
417
      Last_Dlm := Not_A_Dlm;
 
418
 
 
419
      case Op is
 
420
         when A_Concatenate_Operator =>
 
421
            PP_Word ("&");
 
422
            Last_Dlm := Ampersand_Dlm;
 
423
 
 
424
         when A_Multiply_Operator =>
 
425
            PP_Word ("*");
 
426
            Last_Dlm := Asterisk_Dlm;
 
427
 
 
428
         when A_Unary_Plus_Operator |
 
429
              A_Plus_Operator       =>
 
430
            PP_Word ("+");
 
431
            Last_Dlm := Plus_Dlm;
 
432
 
 
433
         when A_Unary_Minus_Operator |
 
434
              A_Minus_Operator       =>
 
435
            PP_Word ("-");
 
436
            Last_Dlm := Minus_Dlm;
 
437
 
 
438
         when A_Divide_Operator =>
 
439
            PP_Word ("/");
 
440
            Last_Dlm := Divide_Dlm;
 
441
 
 
442
         when A_Less_Than_Operator =>
 
443
            PP_Word ("<");
 
444
            Last_Dlm := Less_Than_Dlm;
 
445
 
 
446
         when An_Equal_Operator =>
 
447
            PP_Word ("=");
 
448
            Last_Dlm := Equals_Dlm;
 
449
 
 
450
         when A_Greater_Than_Operator =>
 
451
            PP_Word (">");
 
452
            Last_Dlm := Greater_Than_Dlm;
 
453
 
 
454
         when An_Exponentiate_Operator =>
 
455
            PP_Word ("**");
 
456
            Last_Dlm := Double_Star_Dlm;
 
457
 
 
458
         when A_Not_Equal_Operator =>
 
459
            PP_Word ("/=");
 
460
            Last_Dlm := Inequality_Dlm;
 
461
 
 
462
         when A_Greater_Than_Or_Equal_Operator =>
 
463
            PP_Word (">=");
 
464
            Last_Dlm := Greater_Or_Equal_Dlm;
 
465
 
 
466
         when A_Less_Than_Or_Equal_Operator =>
 
467
            PP_Word ("<=");
 
468
            Last_Dlm := Less_Or_Equal_Dlm;
 
469
 
 
470
         when An_And_Operator =>
 
471
            PP_Keyword (KW_And);
 
472
 
 
473
         when An_Or_Operator =>
 
474
            PP_Keyword (KW_Or);
 
475
 
 
476
         when An_Xor_Operator =>
 
477
            PP_Keyword (KW_Xor);
 
478
 
 
479
         when A_Mod_Operator =>
 
480
            PP_Keyword (KW_Mod);
 
481
 
 
482
         when A_Rem_Operator =>
 
483
            PP_Keyword (KW_Rem);
 
484
 
 
485
         when An_Abs_Operator =>
 
486
            PP_Keyword (KW_Abs);
 
487
 
 
488
         when A_Not_Operator =>
 
489
            PP_Keyword (KW_Not);
 
490
 
 
491
         when others =>
 
492
            null;
 
493
      end case;
 
494
 
 
495
      if Op = A_Unary_Minus_Operator or else
 
496
         Op = A_Unary_Plus_Operator
 
497
      then
 
498
         Unary_Adding_Op_Just_Printed := True;
 
499
      else
 
500
         Unary_Adding_Op_Just_Printed := False;
 
501
      end if;
 
502
 
 
503
      Last_Char_Was_Space := False;
 
504
 
 
505
   end PP_Operator;
 
506
 
 
507
   ------------
 
508
   -- PP_Pad --
 
509
   ------------
 
510
 
 
511
   procedure PP_Pad (N : Natural) is
 
512
   begin
 
513
 
 
514
      if N = 0 then
 
515
         return;
 
516
      end if;
 
517
 
 
518
      Postponed_Space := False;
 
519
 
 
520
      for J in 1 .. N - 1 loop
 
521
         Put (" ");
 
522
      end loop;
 
523
 
 
524
      Output_Pos := Output_Pos + N - 1;
 
525
 
 
526
      if N > 1 then
 
527
         Last_Char_Was_Space := True;
 
528
      end if;
 
529
 
 
530
   end PP_Pad;
 
531
 
 
532
   ------------------
 
533
   -- PP_Pad_Up_To --
 
534
   ------------------
 
535
 
 
536
   procedure PP_Pad_Up_To (N : Natural) is
 
537
   begin
 
538
 
 
539
      if N >= Output_Pos then
 
540
         PP_Pad (N - Output_Pos + 1);
 
541
         Last_Char_Was_Space := True;
 
542
      end if;
 
543
 
 
544
   end PP_Pad_Up_To;
 
545
 
 
546
   ------------------------
 
547
   -- PP_Postponed_Space --
 
548
   ------------------------
 
549
 
 
550
   procedure PP_Postponed_Space is
 
551
   begin
 
552
 
 
553
      if Postponed_Space and then
 
554
         not Last_Char_Was_Space
 
555
      then
 
556
         PP_Space;
 
557
         Postponed_Space := False;
 
558
      end if;
 
559
 
 
560
   end PP_Postponed_Space;
 
561
 
 
562
   --------------
 
563
   -- PP_Space --
 
564
   --------------
 
565
 
 
566
   procedure PP_Space is
 
567
   begin
 
568
 
 
569
      if Output_Pos < Max_Line_Length then
 
570
         Put (" ");
 
571
         Output_Pos := Output_Pos + 1;
 
572
         Last_Char_Was_Space := True;
 
573
      end if;
 
574
 
 
575
   end PP_Space;
 
576
 
 
577
   ------------------------
 
578
   -- PP_Space_If_Needed --
 
579
   ------------------------
 
580
 
 
581
   procedure PP_Space_If_Needed is
 
582
   begin
 
583
 
 
584
      if not Last_Char_Was_Space then
 
585
         PP_Space;
 
586
      end if;
 
587
 
 
588
   end PP_Space_If_Needed;
 
589
 
 
590
   -------------
 
591
   -- PP_Word --
 
592
   -------------
 
593
 
 
594
   procedure PP_Word (S : Program_Text) is
 
595
   begin
 
596
      PP_Word_No_Move (S);
 
597
 
 
598
      Line_Pos := Line_Pos + S'Length;
 
599
 
 
600
      if Line_Pos > Line_Len then
 
601
         Line_Pos := 0;
 
602
      end if;
 
603
 
 
604
      Last_KW  := Not_A_KW;
 
605
      Last_Dlm := Not_A_Dlm;
 
606
 
 
607
   end PP_Word;
 
608
 
 
609
   ---------------------
 
610
   -- PP_Word_No_Move --
 
611
   ---------------------
 
612
 
 
613
   procedure PP_Word_No_Move (S : Program_Text) is
 
614
   begin
 
615
 
 
616
      if S'Length > Available_In_Output then
 
617
         Error ("the line is too long");
 
618
 
 
619
         if not Is_New_Output_Line then
 
620
            PP_Close_Line;
 
621
         end if;
 
622
 
 
623
      end if;
 
624
 
 
625
      Put (S);
 
626
      Output_Pos := Output_Pos + S'Length;
 
627
      Is_New_Output_Line := False;
 
628
 
 
629
      Last_KW  := Not_A_KW;
 
630
      Last_Dlm := Not_A_Dlm;
 
631
 
 
632
      Last_Char_Was_Space := False;
 
633
   end PP_Word_No_Move;
 
634
 
 
635
   ------------------------
 
636
   -- Space_Just_Printed --
 
637
   ------------------------
 
638
 
 
639
   function Space_Just_Printed return Boolean is
 
640
   begin
 
641
      return Last_Char_Was_Space;
 
642
   end Space_Just_Printed;
 
643
 
 
644
end GNATPP.PP_Output;