Debian Codegraph @

progs/arm_mast.adb

raw
1 with Ada.Text_IO,
2 Ada.Characters.Handling,
3 Ada.Strings.Fixed,
4 Ada.Strings.Unbounded;
5 with ARM_Input,
6 ARM_File,
7 --ARM_Format, redundant
8 ARM_Output,
9 ARM_Text,
10 ARM_Texinfo,
11 ARM_HTML,
12 ARM_RTF,
13 ARM_Corr;
14 --ARM_Master,
15 --ARM_Contents;
16 package body ARM_Master is
17
18 --
19 -- Ada reference manual formatter (ARM_Form).
20 --
21 -- This package contains the routines to parse the master file, and
22 -- execute it.
23 --
24 -- ---------------------------------------
25 -- Copyright 2006, 2007, 2009, 2011, 2012, 2013, 2016, 2018
26 -- AXE Consultants. All rights reserved.
27 -- P.O. Box 1512, Madison WI 53701
28 -- E-Mail: [email protected]
29 --
30 -- ARM_Form is free software: you can redistribute it and/or modify
31 -- it under the terms of the GNU General Public License version 3
32 -- as published by the Free Software Foundation.
33 --
34 -- AXE CONSULTANTS MAKES THIS TOOL AND SOURCE CODE AVAILABLE ON AN "AS IS"
35 -- BASIS AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY,
36 -- CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR FUNCTIONING OF THIS TOOL.
37 -- IN NO EVENT WILL AXE CONSULTANTS BE LIABLE FOR ANY GENERAL,
38 -- CONSEQUENTIAL, INDIRECT, INCIDENTAL, EXEMPLARY, OR SPECIAL DAMAGES,
39 -- EVEN IF AXE CONSULTANTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
40 -- DAMAGES.
41 --
42 -- A copy of the GNU General Public License is available in the file
43 -- gpl-3-0.txt in the standard distribution of the ARM_Form tool.
44 -- Otherwise, see <http://www.gnu.org/licenses/>.
45 --
46 -- If the GPLv3 license is not satisfactory for your needs, a commercial
47 -- use license is available for this tool. Contact Randy at AXE Consultants
48 -- for more information.
49 --
50 -- ---------------------------------------
51 --
52 -- Edit History:
53 --
54 -- 1/05/06 - RLB - Created base package to replace hard-coded main program.
55 -- 1/11/06 - RLB - Continued expanding this; revised to handle separate
56 -- creations for the various kinds of output objects.
57 -- 1/12/06 - RLB - Added more commands for additional properties.
58 -- 1/18/06 - RLB - Added the ExampleFont command.
59 -- 1/27/06 - RLB - Added HTMLTabs command.
60 -- 2/19/06 - RLB - Set Number_Paragraphs for HTML.
61 -- 6/22/06 - RLB - Added LinkNonTerminals command.
62 -- 9/21/06 - RLB - Added the Body_Font command.
63 -- 9/22/06 - RLB - Added the Note_Format command.
64 -- 9/25/06 - RLB - Added the Contents_Format command.
65 -- 10/04/06 - RLB - Added the List_Format command.
66 -- 10/13/06 - RLB - Added specifiable default HTML colors.
67 -- 12/19/07 - RLB - Added MS-DOS file names.
68 -- 5/04/09 - RLB - Added the RTFFooter command.
69 -- 5/06/09 - RLB - Added the RTFVersionName command.
70 -- 10/18/11 - RLB - Changed to GPLv3 license.
71 -- 10/19/11 - RLB - Added Texinfo output (from Stephen Leake).
72 -- 8/31/12 - RLB - Added Output_Path.
73 -- 11/26/12 - RLB - Added Subdivision_Names.
74 -- 3/26/13 - RLB - Added HTMLScript.
75 -- 3/17/16 - RLB - Added Base_Change_Version.
76 -- 4/20/16 - RLB - Added HTML_New_Revision_Colors.
77
78 type Command_Type is (
79 -- Source commands:
80 Source, TOC,
81 -- Global properties:
82 Show_Index_Entries,
83 Hide_Index_Entries,
84 Show_Annotations,
85 Hide_Annotations,
86 Show_ISO,
87 Hide_ISO,
88 Link_Non_Terminals,
89 Number_Paragraphs,
90 Title,
91 File_Prefix,
92 Example_Font,
93 Body_Font,
94 Note_Format,
95 Contents_Format,
96 List_Format,
97 Subdivision_Names,
98
99 -- HTML properties:
100 Single_HTML_Output_File,
101 Use_MS_DOS_Names,
102 HTML_Kind_Command,
103 HTML_Nav_Bar,
104 HTML_Tabs,
105 HTML_Script,
106 HTML_Header,
107 HTML_Footer,
108 HTML_Color,
109 HTML_New_Revision_Colors,
110 -- RTF properties:
111 Single_RTF_Output_File,
112 RTF_Header_Prefix,
113 RTF_Footer_Text,
114 RTF_Footer,
115 RTF_Page_Size,
116 RTF_Fonts,
117 RTF_Version_Name,
118 -- Other commands:
119 Comment, Unknown);
120
121 type Source_Kind is (A_File, TOC, Empty);
122
123 type Source_Item (Kind : Source_Kind := Empty) is record
124 case Kind is
125 when Empty => null; -- This item includes no source item.
126 when TOC => null; -- No info for this, it just holds a
127 -- place in the collating order.
128 when A_File =>
129 File_Name : String(1..80);
130 File_Name_Len : Natural;
131 Section_Name : String(1..10);
132 Section_Name_Len : Natural;
133 Section_Number : ARM_Contents.Section_Number_Type;
134 Starts_New_Section : Boolean;
135 end case;
136 end record;
137
138 subtype Source_Count is Integer range 0 .. 100;
139 subtype Source_Index is Source_Count range 1 .. Source_Count'Last;
140 Source_Data : array (Source_Index) of Source_Item;
141 Source_Length : Source_Count := 0;
142
143 -- Command line (global) properties:
144 Change_Kind : ARM_Format.Change_Kind; -- Changes to generate.
145 Change_Version : ARM_Contents.Change_Version_Type; -- Change version.
146 Base_Change_Version : ARM_Contents.Change_Version_Type; -- Change version.
147
148 -- Global properties:
149 Display_Index_Entries : Boolean := False; -- Should Index entries be displayed?
150 Document_Title : ARM_Contents.Versioned_String; -- Document title.
151 Output_File_Prefix : Ada.Strings.Unbounded.Unbounded_String; -- Output file prefix.
152 Include_Annotations : Boolean := False; -- Should annotations be included in the output?
153 Include_ISO_Text : Boolean := False; -- Should ISO text be included in the output?
154 Should_Link_Non_Terminals : Boolean := False; -- Should non-terminals be linked?
155 Should_Number_Paragraphs : Boolean := False; -- Should paragraphs be numbered?
156 Font_of_Examples : ARM_Output.Font_Family_Type :=
157 ARM_Output.Fixed; -- Which font should be used for examples?
158 Font_of_Body : ARM_Output.Font_Family_Type :=
159 ARM_Output.Roman; -- Which font should be used for the body?
160 Use_ISO_2004_Note_Format : Boolean := True;
161 -- Should we use the ISO 2004 note format, or the one used in the
162 -- Ada 95 standard??
163 Use_ISO_2004_Contents_Format : Boolean := True;
164 -- Should we use the ISO 2004 contents format, or the one used in the
165 -- Ada 95 standard??
166 Use_ISO_2004_List_Format : Boolean := True;
167 -- Should we use the ISO 2004 list format, or the one used in the
168 -- Ada 95 standard??
169 Subdivision_Name_Kind : ARM_Output.Top_Level_Subdivision_Name_Kind :=
170 ARM_Output.Section;
171
172 -- HTML properties:
173 Use_Large_HTML_Files : Boolean := False; -- Use small output files by default.
174 Use_MS_DOS_Filenames : Boolean := False; -- Use long file names by default.
175 HTML_Kind : ARM_HTML.HTML_Type := ARM_HTML.HTML_4_Compatible;
176 HTML_Use_Unicode : Boolean := False;
177 HTML_Index_URL : Ada.Strings.Unbounded.Unbounded_String;
178 HTML_Ref_URL : Ada.Strings.Unbounded.Unbounded_String;
179 HTML_Srch_URL : Ada.Strings.Unbounded.Unbounded_String;
180 HTML_Use_Buttons : Boolean := True;
181 HTML_Nav_On_Top : Boolean := True;
182 HTML_Nav_On_Bottom : Boolean := True;
183 HTML_Tab_Emulation : ARM_HTML.Tab_Emulation_Type := ARM_HTML.Emulate_Fixed_Only;
184 HTML_Script_Text : Ada.Strings.Unbounded.Unbounded_String; -- Empty by default.
185 HTML_Header_Text : Ada.Strings.Unbounded.Unbounded_String; -- Empty by default.
186 HTML_Footer_Text : Ada.Strings.Unbounded.Unbounded_String; -- Empty by default.
187 HTML_Use_New_Revision_Colors : Boolean := False;
188 HTML_Text_Color : ARM_HTML.Color_String := "#000000";
189 HTML_Background_Color : ARM_HTML.Color_String := "#FFFFF0";
190 HTML_Link_Color : ARM_HTML.Color_String := "#0000FF";
191 HTML_VLink_Color : ARM_HTML.Color_String := "#800080";
192 HTML_ALink_Color : ARM_HTML.Color_String := "#FF0000";
193
194 -- RTF properties:
195 Use_Large_RTF_Files : Boolean := False; -- Use small output files by default.
196 Header_Prefix : ARM_Contents.Versioned_String;
197 Footer_Text : ARM_Contents.Versioned_String;
198 Footer_Use_Date : Boolean := True; -- Use the date by default.
199 Footer_Use_Clause_Name : Boolean := True; -- Use the clause name rather than the text above by default.
200 Footer_Use_ISO_Format : Boolean := False; -- Use the normal format.
201 Version_Name : ARM_Contents.Versioned_String;
202
203 Page_Size : ARM_RTF.Page_Size := ARM_RTF.Letter; -- Use Letter size by default.
204 Serif_Font : ARM_RTF.Serif_Fonts := ARM_RTF.Times_New_Roman; -- Use Times by default.
205 Sans_Serif_Font : ARM_RTF.Sans_Serif_Fonts := ARM_RTF.Arial; -- Use Arial by default.
206
207 function "+" (Source : Ada.Strings.Unbounded.Unbounded_String) return String
208 renames Ada.Strings.Unbounded.To_String;
209
210 function "+" (Source : String) return Ada.Strings.Unbounded.Unbounded_String
211 renames Ada.Strings.Unbounded.To_Unbounded_String;
212
213 function Decode_Command (Name : in ARM_Input.Command_Name_Type) return Command_Type is
214 -- Return the command value for a particular command name:
215 Canonical_Name : constant String :=
216 Ada.Characters.Handling.To_Lower (Ada.Strings.Fixed.Trim (Name, Ada.Strings.Right));
217 begin
218 if Canonical_Name = "source" then
219 return Source;
220 elsif Canonical_Name = "toc" then
221 return TOC;
222 elsif Canonical_Name = "showindexentries" then
223 return Show_Index_Entries;
224 elsif Canonical_Name = "hideindexentries" then
225 return Hide_Index_Entries;
226 elsif Canonical_Name = "showannotations" then
227 return Show_Annotations;
228 elsif Canonical_Name = "hideannotations" then
229 return Hide_Annotations;
230 elsif Canonical_Name = "showiso" then
231 return Show_ISO;
232 elsif Canonical_Name = "hideiso" then
233 return Hide_ISO;
234 elsif Canonical_Name = "linknonterminals" then
235 return Link_Non_Terminals;
236 elsif Canonical_Name = "numberparagraphs" then
237 return Number_Paragraphs;
238 elsif Canonical_Name = "title" then
239 return Title;
240 elsif Canonical_Name = "fileprefix" then
241 return File_Prefix;
242 elsif Canonical_Name = "examplefont" then
243 return Example_Font;
244 elsif Canonical_Name = "bodyfont" then
245 return Body_Font;
246 elsif Canonical_Name = "noteformat" then
247 return Note_Format;
248 elsif Canonical_Name = "contentsformat" then
249 return Contents_Format;
250 elsif Canonical_Name = "listformat" then
251 return List_Format;
252 elsif Canonical_Name = "subdivisionnames" then
253 return Subdivision_Names;
254 elsif Canonical_Name = "singlehtmloutputfile" then
255 return Single_HTML_Output_File;
256 elsif Canonical_Name = "usemsdosfilenames" then
257 return Use_MS_DOS_Names;
258 elsif Canonical_Name = "htmlkind" then
259 return HTML_Kind_Command;
260 elsif Canonical_Name = "htmlnavbar" then
261 return HTML_Nav_Bar;
262 elsif Canonical_Name = "htmltabs" then
263 return HTML_Tabs;
264 elsif Canonical_Name = "htmlscript" then
265 return HTML_Script;
266 elsif Canonical_Name = "htmlheader" then
267 return HTML_Header;
268 elsif Canonical_Name = "htmlfooter" then
269 return HTML_Footer;
270 elsif Canonical_Name = "htmlnewrevisioncolors" then
271 return HTML_New_Revision_Colors;
272 elsif Canonical_Name = "htmlcolor" then
273 return HTML_Color;
274 elsif Canonical_Name = "singlertfoutputfile" then
275 return Single_RTF_Output_File;
276 elsif Canonical_Name = "rtfheaderprefix" then
277 return RTF_Header_Prefix;
278 elsif Canonical_Name = "rtffootertext" then
279 return RTF_Footer_Text;
280 elsif Canonical_Name = "rtffooter" then
281 return RTF_Footer;
282 elsif Canonical_Name = "rtfpagesize" then
283 return RTF_Page_Size;
284 elsif Canonical_Name = "rtffonts" then
285 return RTF_Fonts;
286 elsif Canonical_Name = "rtfversionname" then
287 return RTF_Version_Name;
288 elsif Canonical_Name = "comment" then
289 return Comment;
290 else
291 return Unknown;
292 end if;
293 end Decode_Command;
294
295
296 function Get_Versioned_String (Item_Details : in ARM_Contents.Versioned_String;
297 For_Version : in ARM_Contents.Change_Version_Type)
298 return String is
299 -- Get a versioned item for the appropriate version.
300 use type Ada.Strings.Unbounded.Unbounded_String;
301 begin
302 for I in reverse ARM_Contents.Change_Version_Type'First .. For_Version loop
303 if Item_Details(I) /= Ada.Strings.Unbounded.Null_Unbounded_String then
304 return +Item_Details(I);
305 -- else keep looking, not defined for this version.
306 end if;
307 end loop;
308 return ""; -- Not defined for any version.
309 end Get_Versioned_String;
310
311
312 procedure Read_Master_File (Input_Object : in out ARM_Input.Input_Type'Class) is
313 -- Read the master file, saving the information into data structures
314 -- here.
315
316 procedure Process_Command is
317 Command_Name : ARM_Input.Command_Name_Type;
318 Ch : Character;
319 -- use type ARM_Output.Size_Type;
320 Command : Command_Type;
321
322 Close_Ch : Character;
323 procedure Get_Open_Char is
324 -- Get an open character, setting Close_Ch appropriately;
325 -- generate an error if there isn't one.
326 Ch : Character;
327 begin
328 ARM_Input.Get_Char (Input_Object, Ch);
329 if ARM_Input.Is_Open_Char (Ch) then -- Start parameter:
330 Close_Ch := ARM_Input.Get_Close_Char (Ch);
331 else
332 Ada.Text_IO.Put_Line ("** Parameter missing for command on line" & ARM_Input.Line_String (Input_Object));
333 Close_Ch := ' ';
334 end if;
335 end Get_Open_Char;
336
337 function Get_Single_String return String is
338 -- Returns the (single) parameter of a command.
339 Item : String(1..2000);
340 ILen : Natural := 0;
341 begin
342 Get_Open_Char;
343 if Close_Ch /= ' ' then
344 -- Copy over the string:
345 ARM_Input.Copy_to_String_until_Close_Char (
346 Input_Object,
347 Close_Ch,
348 Item,
349 ILen);
350 return Item(1..ILen);
351 else -- didn't find an opening character.
352 return "";
353 end if;
354 end Get_Single_String;
355
356 procedure Get_Boolean (Param_Name : in ARM_Input.Command_Name_Type;
357 Result : out Boolean;
358 Is_First : in Boolean := False) is
359 -- Get a boolean value from a parameter named Param_Name.
360 Ch, Close_Ch : Character;
361 begin
362 ARM_Input.Check_Parameter_Name (Input_Object,
363 Param_Name => Param_Name,
364 Is_First => Is_First,
365 Param_Close_Bracket => Close_Ch);
366 if Close_Ch /= ' ' then
367 -- Get the Boolean character:
368 ARM_Input.Get_Char (Input_Object, Ch);
369 --Ada.Text_IO.Put_Line(" Bool=" & Ch);
370 case Ch is
371 when 'F' | 'f' | 'N' | 'n' =>
372 Result := False;
373 when 'T' | 't' | 'Y' | 'y' =>
374 Result := True;
375 when others =>
376 Ada.Text_IO.Put_Line (" ** Bad value for boolean parameter " &
377 Ada.Strings.Fixed.Trim (Param_Name, Ada.Strings.Right) &
378 " on line " & ARM_Input.Line_String (Input_Object));
379 end case;
380 ARM_Input.Get_Char (Input_Object, Ch);
381 if Ch /= Close_Ch then
382 Ada.Text_IO.Put_Line (" ** Bad close for boolean parameter " &
383 Ada.Strings.Fixed.Trim (Param_Name, Ada.Strings.Right) &
384 " on line " & ARM_Input.Line_String (Input_Object));
385 ARM_Input.Replace_Char (Input_Object);
386 end if;
387 -- else no parameter. Weird.
388 end if;
389 end Get_Boolean;
390
391 procedure Process_Versioned_String (Item : in out ARM_Contents.Versioned_String) is
392 -- @Command{Version=[<Version>],Text=[<Text>]}
393 Param_Close_Ch, Ch : Character;
394 Text : String(1..80);
395 TLen : Natural := 0;
396 Version : ARM_Contents.Change_Version_Type;
397 begin
398 --Ada.Text_IO.Put_Line("Process versioned item command");
399 Get_Open_Char;
400 ARM_Input.Check_Parameter_Name (Input_Object,
401 Param_Name => "Version" & (8..ARM_Input.Command_Name_Type'Last => ' '),
402 Is_First => True,
403 Param_Close_Bracket => Param_Close_Ch);
404 if Param_Close_Ch /= ' ' then
405 -- Get the version character:
406 ARM_Input.Get_Char (Input_Object, Ch);
407 Version := ARM_Contents.Change_Version_Type(Ch);
408 --Ada.Text_IO.Put_Line(" Version=" & Version);
409 ARM_Input.Get_Char (Input_Object, Ch);
410 if Ch /= Param_Close_Ch then
411 Ada.Text_IO.Put_Line (" ** Bad close for change version on line " & ARM_Input.Line_String (Input_Object));
412 ARM_Input.Replace_Char (Input_Object);
413 end if;
414 -- else no parameter. Weird.
415 end if;
416
417 ARM_Input.Check_Parameter_Name (Input_Object,
418 Param_Name => "Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
419 Is_First => False,
420 Param_Close_Bracket => Param_Close_Ch);
421 if Param_Close_Ch /= ' ' then
422 -- Copy over the term:
423 ARM_Input.Copy_to_String_until_Close_Char (
424 Input_Object,
425 Param_Close_Ch,
426 Text,
427 TLen);
428 --Ada.Text_IO.Put_Line(" Text=" & Text(1..TLen));
429 Item(Version) := +Text(1..TLen);
430 -- else no parameter, error already produced.
431 end if;
432
433 ARM_Input.Get_Char (Input_Object, Ch);
434 if Ch = Close_Ch then
435 null;
436 else
437 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
438 ARM_Input.Replace_Char (Input_Object);
439 end if;
440 end Process_Versioned_String;
441
442 procedure Process_RTF_Fonts is
443 -- @RTFFonts{Serif=[Times|Souvenir]},SansSerif=[Arial|Helvetica]}
444 Param_Close_Ch : Character;
445 Item : String(1..80);
446 ILen : Natural := 0;
447 begin
448 Get_Open_Char;
449 --Ada.Text_IO.Put_Line("Process RTF Fonts");
450 ARM_Input.Check_Parameter_Name (Input_Object,
451 Param_Name => "Serif" & (6..ARM_Input.Command_Name_Type'Last => ' '),
452 Is_First => True,
453 Param_Close_Bracket => Param_Close_Ch);
454 if Param_Close_Ch /= ' ' then
455 -- Copy over the font name:
456 ARM_Input.Copy_to_String_until_Close_Char (
457 Input_Object,
458 Param_Close_Ch,
459 Item,
460 ILen);
461 Ada.Text_IO.Put_Line("RTF Serif Font=" & Item(1..ILen));
462 declare
463 Name : constant String :=
464 Ada.Characters.Handling.To_Lower (Item(1..ILen));
465 begin
466 if Name = "times" then
467 Serif_Font := ARM_RTF.Times_New_Roman;
468 elsif Name = "souvenir" then
469 Serif_Font := ARM_RTF.Souvenir;
470 else
471 Ada.Text_IO.Put_Line ("** Unknown serif font name: " & Name &
472 " on line" & ARM_Input.Line_String (Input_Object));
473 end if;
474 end;
475 -- else no parameter, error already produced.
476 end if;
477 ARM_Input.Check_Parameter_Name (Input_Object,
478 Param_Name => "SansSerif" & (10..ARM_Input.Command_Name_Type'Last => ' '),
479 Is_First => False,
480 Param_Close_Bracket => Param_Close_Ch);
481 if Param_Close_Ch /= ' ' then
482 -- Copy over the font name:
483 ARM_Input.Copy_to_String_until_Close_Char (
484 Input_Object,
485 Param_Close_Ch,
486 Item,
487 ILen);
488 Ada.Text_IO.Put_Line("RTF Sans_Serif Font=" & Item(1..ILen));
489 declare
490 Name : constant String :=
491 Ada.Characters.Handling.To_Lower (Item(1..ILen));
492 begin
493 if Name = "arial" then
494 Sans_Serif_Font := ARM_RTF.Arial;
495 elsif Name = "helvetica" then
496 Sans_Serif_Font := ARM_RTF.Helvetica;
497 else
498 Ada.Text_IO.Put_Line ("** Unknown serif font name: " & Name &
499 " on line" & ARM_Input.Line_String (Input_Object));
500 end if;
501 end;
502 -- else no parameter, error already produced.
503 end if;
504 ARM_Input.Get_Char (Input_Object, Ch);
505 if Ch = Close_Ch then
506 null;
507 else
508 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
509 ARM_Input.Replace_Char (Input_Object);
510 end if;
511 end Process_RTF_Fonts;
512
513 procedure Process_HTML_Kind is
514 -- @HTMLKind{Version=[3|4Comp|4],Unicode=[T|F]}
515 Param_Close_Ch : Character;
516 Item : String(1..80);
517 ILen : Natural := 0;
518 begin
519 Get_Open_Char;
520 --Ada.Text_IO.Put_Line("Process HTML Kind");
521 ARM_Input.Check_Parameter_Name (Input_Object,
522 Param_Name => "Version" & (8..ARM_Input.Command_Name_Type'Last => ' '),
523 Is_First => True,
524 Param_Close_Bracket => Param_Close_Ch);
525 if Param_Close_Ch /= ' ' then
526 -- Copy over the version:
527 ARM_Input.Copy_to_String_until_Close_Char (
528 Input_Object,
529 Param_Close_Ch,
530 Item,
531 ILen);
532 Ada.Text_IO.Put_Line("HTML version and kind=" & Item(1..ILen));
533 declare
534 Kind : constant String :=
535 Ada.Characters.Handling.To_Lower (Item(1..ILen));
536 begin
537 if Kind = "3" then
538 HTML_Kind := ARM_HTML.HTML_3;
539 elsif Kind = "4comp" then
540 HTML_Kind := ARM_HTML.HTML_4_Compatible;
541 elsif Kind = "4" then
542 HTML_Kind := ARM_HTML.HTML_4_Only;
543 else
544 Ada.Text_IO.Put_Line ("** Unknown HTML version: " & Kind &
545 " on line" & ARM_Input.Line_String (Input_Object));
546 end if;
547 end;
548 -- else no parameter, error already produced.
549 end if;
550
551 Get_Boolean ("Unicode" & (8..ARM_Input.Command_Name_Type'Last => ' '),
552 HTML_Use_Unicode);
553 if HTML_Use_Unicode then
554 Ada.Text_IO.Put_Line("HTML will use Unicode characters where appropriate");
555 else
556 Ada.Text_IO.Put_Line("HTML will use Unicode characters only when explicitly requested");
557 end if;
558
559 ARM_Input.Get_Char (Input_Object, Ch);
560 if Ch = Close_Ch then
561 null;
562 else
563 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
564 ARM_Input.Replace_Char (Input_Object);
565 end if;
566 end Process_HTML_Kind;
567
568 procedure Process_HTML_Nav_Bar is
569 --@HTMLNavBar{RefName=[<URL>],SrchName=[<URL>],
570 -- UseButtons=[T|F],OnTop=[T|F],OnBottom=[T|F]}
571 Param_Close_Ch : Character;
572 Item : String(1..80);
573 ILen : Natural := 0;
574 begin
575 Get_Open_Char;
576 --Ada.Text_IO.Put_Line("Process HTML Nav Bar");
577 ARM_Input.Check_Parameter_Name (Input_Object,
578 Param_Name => "RefName" & (8..ARM_Input.Command_Name_Type'Last => ' '),
579 Is_First => True,
580 Param_Close_Bracket => Param_Close_Ch);
581 if Param_Close_Ch /= ' ' then
582 -- Copy over the version:
583 ARM_Input.Copy_to_String_until_Close_Char (
584 Input_Object,
585 Param_Close_Ch,
586 Item,
587 ILen);
588 Ada.Text_IO.Put_Line("HTML reference URL=" & Item(1..ILen));
589 HTML_Ref_Url := + Item(1..ILen);
590 -- else no parameter, error already produced.
591 end if;
592
593 ARM_Input.Check_Parameter_Name (Input_Object,
594 Param_Name => "SrchName" & (9..ARM_Input.Command_Name_Type'Last => ' '),
595 Is_First => False,
596 Param_Close_Bracket => Param_Close_Ch);
597 if Param_Close_Ch /= ' ' then
598 -- Copy over the version:
599 ARM_Input.Copy_to_String_until_Close_Char (
600 Input_Object,
601 Param_Close_Ch,
602 Item,
603 ILen);
604 Ada.Text_IO.Put_Line("HTML search URL=" & Item(1..ILen));
605 HTML_Srch_Url := + Item(1..ILen);
606 -- else no parameter, error already produced.
607 end if;
608
609 ARM_Input.Check_Parameter_Name (Input_Object,
610 Param_Name => "IndexName" & (10..ARM_Input.Command_Name_Type'Last => ' '),
611 Is_First => False,
612 Param_Close_Bracket => Param_Close_Ch);
613 if Param_Close_Ch /= ' ' then
614 -- Copy over the version:
615 ARM_Input.Copy_to_String_until_Close_Char (
616 Input_Object,
617 Param_Close_Ch,
618 Item,
619 ILen);
620 Ada.Text_IO.Put_Line("HTML index URL=" & Item(1..ILen));
621 HTML_Index_Url := + Item(1..ILen);
622 -- else no parameter, error already produced.
623 end if;
624
625 Get_Boolean ("UseButtons" & (11..ARM_Input.Command_Name_Type'Last => ' '),
626 HTML_Use_Buttons);
627 if HTML_Use_Buttons then
628 Ada.Text_IO.Put_Line("HTML navigation will use buttons");
629 else
630 Ada.Text_IO.Put_Line("HTML navigation will use text labels");
631 end if;
632
633 Get_Boolean ("OnTop" & (6..ARM_Input.Command_Name_Type'Last => ' '),
634 HTML_Nav_On_Top);
635 if HTML_Nav_On_Top then
636 Ada.Text_IO.Put_Line("HTML navigation bar will appear on top of pages");
637 end if;
638
639 Get_Boolean ("OnBottom" & (9..ARM_Input.Command_Name_Type'Last => ' '),
640 HTML_Nav_On_Bottom);
641 if HTML_Nav_On_Bottom then
642 Ada.Text_IO.Put_Line("HTML navigation bar will appear on bottom of pages");
643 end if;
644
645 ARM_Input.Get_Char (Input_Object, Ch);
646 if Ch = Close_Ch then
647 null;
648 else
649 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
650 ARM_Input.Replace_Char (Input_Object);
651 end if;
652 end Process_HTML_Nav_Bar;
653
654 procedure Process_HTML_Color is
655 --@HTMLColor{Text=[<Color]>,Background=[<Color>],
656 -- Link=[<Color>],VLink=[<Color>],ALink=[<Color>]}
657
658 procedure Get_Color (Param_Name : in ARM_Input.Command_Name_Type;
659 Is_First : in Boolean;
660 Result : out ARM_HTML.Color_String) is
661 -- Get a color value from a parameter named Param_Name.
662 Ch, Close_Ch : Character;
663 Color : ARM_HTML.Color_String := (others => ' ');
664 begin
665 ARM_Input.Check_Parameter_Name (Input_Object,
666 Param_Name => Param_Name,
667 Is_First => Is_First,
668 Param_Close_Bracket => Close_Ch);
669 if Close_Ch /= ' ' then
670 -- Get the color characters:
671 for I in ARM_HTML.Color_String'range loop
672 ARM_Input.Get_Char (Input_Object, Ch);
673 if Ch = Close_Ch then
674 Ada.Text_IO.Put_Line (" ** HTML color too short for " &
675 Ada.Strings.Fixed.Trim (Param_Name, Ada.Strings.Right) &
676 " on line " & ARM_Input.Line_String (Input_Object));
677 ARM_Input.Replace_Char (Input_Object);
678 exit;
679 end if;
680 Color(I) := Ch;
681 end loop;
682 --Ada.Text_IO.Put_Line(" Color=" & Color);
683 Result := Color;
684 ARM_Input.Get_Char (Input_Object, Ch);
685 if Ch /= Close_Ch then
686 Ada.Text_IO.Put_Line (" ** Bad close for color parameter " &
687 Ada.Strings.Fixed.Trim (Param_Name, Ada.Strings.Right) &
688 " on line " & ARM_Input.Line_String (Input_Object));
689 ARM_Input.Replace_Char (Input_Object);
690 end if;
691 -- else no parameter. Weird.
692 end if;
693 end Get_Color;
694
695 begin
696 Get_Open_Char;
697 --Ada.Text_IO.Put_Line("Process HTML Color");
698 Get_Color ("Text" & (5..ARM_Input.Command_Name_Type'Last => ' '),
699 Is_First => True, Result => HTML_Text_Color);
700 Ada.Text_IO.Put_Line("HTML text color is " & HTML_Text_Color);
701
702 Get_Color ("Background" & (11..ARM_Input.Command_Name_Type'Last => ' '),
703 Is_First => False, Result => HTML_Background_Color);
704 Ada.Text_IO.Put_Line("HTML background color is " & HTML_Background_Color);
705
706 Get_Color ("Link" & (5..ARM_Input.Command_Name_Type'Last => ' '),
707 Is_First => False, Result => HTML_Link_Color);
708 Ada.Text_IO.Put_Line("HTML link color is " & HTML_Link_Color);
709
710 Get_Color ("VLink" & (6..ARM_Input.Command_Name_Type'Last => ' '),
711 Is_First => False, Result => HTML_VLink_Color);
712 Ada.Text_IO.Put_Line("HTML visited link color is " & HTML_VLink_Color);
713
714 Get_Color ("ALink" & (6..ARM_Input.Command_Name_Type'Last => ' '),
715 Is_First => False, Result => HTML_ALink_Color);
716 Ada.Text_IO.Put_Line("HTML active link color is " & HTML_ALink_Color);
717
718 ARM_Input.Get_Char (Input_Object, Ch);
719 if Ch = Close_Ch then
720 null;
721 else
722 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
723 ARM_Input.Replace_Char (Input_Object);
724 end if;
725 end Process_HTML_Color;
726
727 procedure Process_Source_Command is
728 -- @Source{Name=<File Name>,SectionName=<Name>,
729 -- SectionNumber=<AlphaNum>,NewSection=[T|F]}
730 Param_Close_Ch : Character;
731 Item : String(1..80);
732 ILen : Natural := 0;
733 use type ARM_Contents.Section_Number_Type;
734 begin
735 Get_Open_Char;
736 if Source_Length = Source_Count'Last then
737 Ada.Text_IO.Put_Line ("** Too many source files on line" & ARM_Input.Line_String (Input_Object));
738 else
739 Source_Length := Source_Length + 1;
740 --Ada.Text_IO.Put_Line("Process source command - Length =" & Source_Count'Image(Source_Length));
741 Source_Data(Source_Length) :=
742 (Kind => A_File,
743 File_Name => (others => ' '),
744 File_Name_Len => 0,
745 Section_Name => (others => ' '),
746 Section_Name_Len => 0,
747 Section_Number => 0,
748 Starts_New_Section => True);
749 ARM_Input.Check_Parameter_Name (Input_Object,
750 Param_Name => "Name" & (5..ARM_Input.Command_Name_Type'Last => ' '),
751 Is_First => True,
752 Param_Close_Bracket => Param_Close_Ch);
753 if Param_Close_Ch /= ' ' then
754 -- Copy over the term:
755 ARM_Input.Copy_to_String_until_Close_Char (
756 Input_Object,
757 Param_Close_Ch,
758 Item,
759 ILen);
760 --Ada.Text_IO.Put_Line(" Name=" & Item(1..ILen));
761 if Ada.Strings.Fixed.Index (Item(1..ILen), ".") = 0 then
762 -- Append the extension:
763 Source_Data(Source_Length).File_Name_Len := ILen + 4;
764 Ada.Strings.Fixed.Move (
765 Target => Source_Data(Source_Length).File_Name,
766 Source => Ada.Characters.Handling.To_Lower (Item(1..ILen)) & ".mss");
767 else
768 Source_Data(Source_Length).File_Name_Len := ILen;
769 Ada.Strings.Fixed.Move (
770 Target => Source_Data(Source_Length).File_Name,
771 Source => Ada.Characters.Handling.To_Lower (Item(1..ILen)));
772 end if;
773 -- else no parameter, error already produced.
774 end if;
775 ARM_Input.Check_Parameter_Name (Input_Object,
776 Param_Name => "SectionName" & (12..ARM_Input.Command_Name_Type'Last => ' '),
777 Is_First => False,
778 Param_Close_Bracket => Param_Close_Ch);
779 if Param_Close_Ch /= ' ' then
780 -- Copy over the term:
781 ARM_Input.Copy_to_String_until_Close_Char (
782 Input_Object,
783 Param_Close_Ch,
784 Item,
785 ILen);
786 --Ada.Text_IO.Put_Line(" Section_Name=" & Item(1..ILen));
787 Source_Data(Source_Length).Section_Name_Len := ILen;
788 Ada.Strings.Fixed.Move (
789 Target => Source_Data(Source_Length).Section_Name,
790 Source => Item(1..ILen));
791 -- else no parameter, error already produced.
792 end if;
793 ARM_Input.Check_Parameter_Name (Input_Object,
794 Param_Name => "SectionNumber" & (14..ARM_Input.Command_Name_Type'Last => ' '),
795 Is_First => False,
796 Param_Close_Bracket => Param_Close_Ch);
797 if Param_Close_Ch /= ' ' then
798 -- Copy over the term:
799 ARM_Input.Copy_to_String_until_Close_Char (
800 Input_Object,
801 Param_Close_Ch,
802 Item,
803 ILen);
804 --Ada.Text_IO.Put_Line(" Section_Number=" & Item(1..ILen));
805 if ILen = 1 and then Item(1) in 'A'..'Z' then
806 Source_Data(Source_Length).Section_Number :=
807 31 + Character'Pos(Item(1)) - Character'Pos('A');
808 elsif ILen = 1 and then Item(1) in 'a'..'z' then
809 Source_Data(Source_Length).Section_Number :=
810 31 + Character'Pos(Item(1)) - Character'Pos('a');
811 else
812 begin
813 Source_Data(Source_Length).Section_Number :=
814 ARM_Contents.Section_Number_Type'Value(Item(1..Ilen));
815 exception
816 when Constraint_Error =>
817 Ada.Text_IO.Put_Line ("** Illegal section number " &
818 Item(1..ILen) & " on line" & ARM_Input.Line_String (Input_Object));
819 end;
820 end if;
821 -- else no parameter, error already produced.
822 end if;
823
824 Get_Boolean ("NewSection" & (11..ARM_Input.Command_Name_Type'Last => ' '),
825 Source_Data(Source_Length).Starts_New_Section);
826
827 ARM_Input.Get_Char (Input_Object, Ch);
828 if Ch = Close_Ch then
829 null;
830 else
831 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
832 ARM_Input.Replace_Char (Input_Object);
833 end if;
834 end if;
835 end Process_Source_Command;
836
837 begin
838 -- We don't have any non-identifier commands here, so we can
839 -- go directly to getting the name:
840 ARM_Input.Get_Name (Input_Object, Command_Name);
841 Command := Decode_Command (Command_Name);
842 --Ada.Text_IO.Put_Line("Process command=" & Command_Type'Image(Command));
843 --Ada.Text_IO.Put_Line("Process command=" & Command_Type'Image(Command) & " Name=" & Command_Name);
844
845 case Command is
846 when Comment =>
847 -- @Comment{<text>}
848 -- Skip the parameter.
849 Get_Open_Char;
850 if Close_Ch /= ' ' then
851 ARM_Input.Skip_until_Close_Char (Input_Object, Close_Ch);
852 end if;
853
854 -- Global properties:
855
856 when Show_Index_Entries =>
857 -- @ShowIndexEntries
858 Display_Index_Entries := True;
859 Ada.Text_IO.Put_Line("Show Index Entries");
860
861 when Hide_Index_Entries =>
862 -- @HideIndexEntries
863 Display_Index_Entries := False;
864 Ada.Text_IO.Put_Line("Hide Index Entries");
865
866 when Show_Annotations =>
867 -- @ShowAnnotations
868 Include_Annotations := True;
869 Ada.Text_IO.Put_Line("Show Annotations");
870
871 when Hide_Annotations =>
872 -- @HideAnnotations
873 Include_Annotations := False;
874 Ada.Text_IO.Put_Line("Hide Annotations");
875
876 when Show_ISO =>
877 -- @ShowISO
878 Include_ISO_Text := True;
879 Ada.Text_IO.Put_Line("Show ISO Text");
880
881 when Hide_ISO =>
882 -- @HideISO
883 Include_ISO_Text := False;
884 Ada.Text_IO.Put_Line("Hide ISO Text");
885
886 when Link_Non_Terminals =>
887 -- @LinkNonTerminals
888 Should_Link_Non_Terminals := True;
889 Ada.Text_IO.Put_Line("Link Non-Terminals");
890
891 when Number_Paragraphs =>
892 -- @NumberParagraphs
893 Should_Number_Paragraphs := True;
894 Ada.Text_IO.Put_Line("Number Paragraphs");
895
896 when Title =>
897 -- @Title{Version=[<version>],Text=[<title_text>]}
898 Process_Versioned_String (Document_Title);
899
900 when File_Prefix =>
901 -- @FilePrefix{<File_Prefix>}
902 Output_File_Prefix := +Ada.Characters.Handling.To_Lower (Get_Single_String);
903 Ada.Text_IO.Put_Line("File Prefix is " &
904 (+Output_File_Prefix));
905
906 when Example_Font =>
907 -- @ExampleFont{Swiss|Fixed|Roman}
908 declare
909 Font_Name : constant String :=
910 Ada.Characters.Handling.To_Lower (
911 Get_Single_String);
912 begin
913 if Font_Name = "swiss" then
914 Font_of_Examples := ARM_Output.Swiss;
915 Ada.Text_IO.Put_Line("Examples in swiss font");
916 elsif Font_Name = "fixed" then
917 Font_of_Examples := ARM_Output.Fixed;
918 Ada.Text_IO.Put_Line("Examples in fixed-width font");
919 elsif Font_Name = "roman" then
920 Font_of_Examples := ARM_Output.Roman;
921 Ada.Text_IO.Put_Line("Examples in roman font");
922 else
923 Ada.Text_IO.Put_Line ("** Unknown example font name: " & Font_Name &
924 " on line" & ARM_Input.Line_String (Input_Object));
925 end if;
926 end;
927
928 when Body_Font =>
929 -- @BodyFont{Swiss|Roman}
930 declare
931 Font_Name : constant String :=
932 Ada.Characters.Handling.To_Lower (
933 Get_Single_String);
934 begin
935 if Font_Name = "swiss" then
936 Font_of_Body := ARM_Output.Swiss;
937 Ada.Text_IO.Put_Line("Body in swiss font");
938 elsif Font_Name = "roman" then
939 Font_of_Body := ARM_Output.Roman;
940 Ada.Text_IO.Put_Line("Body in roman font");
941 else
942 Ada.Text_IO.Put_Line ("** Unknown body font name: " & Font_Name &
943 " on line" & ARM_Input.Line_String (Input_Object));
944 end if;
945 end;
946
947 when Note_Format =>
948 -- @NoteFormat{Ada95|ISO2004}
949 declare
950 Format_Name : constant String :=
951 Ada.Characters.Handling.To_Lower (
952 Get_Single_String);
953 begin
954 if Format_Name = "ada95" then
955 Use_ISO_2004_Note_Format := False;
956 Ada.Text_IO.Put_Line("Notes in Ada 95 standard format");
957 elsif Format_Name = "iso2004" then
958 Use_ISO_2004_Note_Format := True;
959 Ada.Text_IO.Put_Line("Notes in ISO 2004 standard format");
960 else
961 Ada.Text_IO.Put_Line ("** Unknown note format name: " & Format_Name &
962 " on line" & ARM_Input.Line_String (Input_Object));
963 end if;
964 end;
965
966 when Contents_Format =>
967 -- @ContentsFormat{Ada95|ISO2004}
968 declare
969 Format_Name : constant String :=
970 Ada.Characters.Handling.To_Lower (
971 Get_Single_String);
972 begin
973 if Format_Name = "ada95" then
974 Use_ISO_2004_Contents_Format := False;
975 Ada.Text_IO.Put_Line("Table of Contents in Ada 95 standard format");
976 elsif Format_Name = "iso2004" then
977 Use_ISO_2004_Contents_Format := True;
978 Ada.Text_IO.Put_Line("Table of Contents in ISO 2004 standard format");
979 else
980 Ada.Text_IO.Put_Line ("** Unknown contents format name: " & Format_Name &
981 " on line" & ARM_Input.Line_String (Input_Object));
982 end if;
983 end;
984
985 when List_Format =>
986 -- @ListFormat{Ada95|ISO2004}
987 declare
988 Format_Name : constant String :=
989 Ada.Characters.Handling.To_Lower (
990 Get_Single_String);
991 begin
992 if Format_Name = "ada95" then
993 Use_ISO_2004_List_Format := False;
994 Ada.Text_IO.Put_Line("Lists in Ada 95 standard format");
995 elsif Format_Name = "iso2004" then
996 Use_ISO_2004_List_Format := True;
997 Ada.Text_IO.Put_Line("Lists in ISO 2004 standard format");
998 else
999 Ada.Text_IO.Put_Line ("** Unknown list format name: " & Format_Name &
1000 " on line" & ARM_Input.Line_String (Input_Object));
1001 end if;
1002 end;
1003
1004 when Subdivision_Names =>
1005 -- @SubdivisionNames{Chapter|Section|Clause}
1006 declare
1007 SD_Name : constant String :=
1008 Ada.Characters.Handling.To_Lower (
1009 Get_Single_String);
1010 begin
1011 if SD_Name = "chapter" then
1012 Subdivision_Name_Kind := ARM_Output.Chapter;
1013 Ada.Text_IO.Put_Line("Top-level subdivisions known as Chapters");
1014 elsif SD_Name = "section" then
1015 Subdivision_Name_Kind := ARM_Output.Section;
1016 Ada.Text_IO.Put_Line("Top-level subdivisions known as Sections");
1017 elsif SD_Name = "clause" then
1018 Subdivision_Name_Kind := ARM_Output.Clause;
1019 Ada.Text_IO.Put_Line("Top-level subdivisions known as Clauses");
1020 else
1021 Ada.Text_IO.Put_Line ("** Unknown subdivision name: " & SD_Name &
1022 " on line" & ARM_Input.Line_String (Input_Object));
1023 end if;
1024 end;
1025
1026 -- HTML properties:
1027
1028 when Single_HTML_Output_File =>
1029 -- @Single_HTML_Output_File
1030 Use_Large_HTML_Files := True;
1031 Ada.Text_IO.Put_Line("Single HTML Output File");
1032
1033 when Use_MS_DOS_Names =>
1034 -- @UseMSDOSFileNames
1035 Use_MS_DOS_Filenames := True;
1036 Ada.Text_IO.Put_Line("Use MS-DOS (8.3) file names for HTML output files");
1037
1038 when HTML_Kind_Command =>
1039 --@HTMLKind{Version=[3|4Comp|4],Unicode=[T|F]}
1040 Process_HTML_Kind;
1041
1042 when HTML_Nav_Bar =>
1043 --@HTMLNavBar{RefName=[<URL>],SrchName=[<URL>],UseButtons=[T|F],OnTop=[T|F],OnBottom=[T|F]}
1044 Process_HTML_Nav_Bar;
1045
1046 when HTML_Tabs =>
1047 -- @HTMLTabs{[SingleSpace|QuadSpace|EmulateFixedOnly|EmulateFixedOnlyQuad|EmulateAll]}
1048 declare
1049 Tabs : constant String :=
1050 Ada.Characters.Handling.To_Lower (Get_Single_String);
1051 begin
1052 if Tabs = "singlespace" then
1053 HTML_Tab_Emulation := ARM_HTML.Single_Space;
1054 elsif Tabs = "quadspace" then
1055 HTML_Tab_Emulation := ARM_HTML.Quad_Space;
1056 elsif Tabs = "emulatefixedonly" then
1057 HTML_Tab_Emulation := ARM_HTML.Emulate_Fixed_Only;
1058 elsif Tabs = "emulatefixedonlyquad" then
1059 HTML_Tab_Emulation := ARM_HTML.Emulate_Fixed_Only_Quad;
1060 elsif Tabs = "emulateall" then
1061 HTML_Tab_Emulation := ARM_HTML.Emulate_All;
1062 else
1063 Ada.Text_IO.Put_Line ("** Unknown tab emulation name: " & Tabs &
1064 " on line" & ARM_Input.Line_String (Input_Object));
1065 end if;
1066 Ada.Text_IO.Put_Line("HTML Tab Emulation is " &
1067 ARM_HTML.Tab_Emulation_Type'Image(HTML_Tab_Emulation));
1068 end;
1069
1070 when HTML_Script =>
1071 --@HTMLHeader{<Script>}
1072 HTML_Script_Text := +Get_Single_String;
1073 if Ada.Strings.Unbounded.Length (HTML_Script_Text) /= 0 then
1074 Ada.Text_IO.Put_Line("Non-empty HTML Script seen");
1075 end if;
1076
1077 when HTML_Header =>
1078 --@HTMLHeader{<HTML_for_Header>}
1079 HTML_Header_Text := +Get_Single_String;
1080 if Ada.Strings.Unbounded.Length (HTML_Header_Text) /= 0 then
1081 Ada.Text_IO.Put_Line("Non-empty HTML Header seen");
1082 end if;
1083
1084 when HTML_Footer =>
1085 --@HTMLFooter{<HTML_for_Footer>}
1086 HTML_Footer_Text := +Get_Single_String;
1087 if Ada.Strings.Unbounded.Length (HTML_Footer_Text) /= 0 then
1088 Ada.Text_IO.Put_Line("Non-empty HTML Footer seen");
1089 end if;
1090
1091 when HTML_New_Revision_Colors =>
1092 -- @HTMLNewRevisionColors
1093 HTML_Use_New_Revision_Colors := True;
1094 Ada.Text_IO.Put_Line("Unconditionally use new revision colors in HTML");
1095
1096 when HTML_Color =>
1097 --@HTMLColor{Text=[<Color]>,Background=[<Color>],
1098 -- Link=[<Color>],VLink=[<Color>],ALink=[<Color>]}
1099 Process_HTML_Color;
1100
1101 -- RTF properties:
1102
1103 when Single_RTF_Output_File =>
1104 -- @Single_RTF_Output_File
1105 Use_Large_RTF_Files := True;
1106 Ada.Text_IO.Put_Line("Single RTF Output File");
1107
1108 when RTF_Header_Prefix =>
1109 -- @RTFHeaderPrefix{Version=[<version>],Text=[<title_text>]}
1110 Process_Versioned_String (Header_Prefix);
1111
1112 when RTF_Footer_Text =>
1113 -- @RTFFooterPrefix{Version=[<version>],Text=[<title_text>]}
1114 Process_Versioned_String (Footer_Text);
1115
1116 when RTF_Footer =>
1117 -- @RTFFooter{UseDate=[T|F],UseClauseName=[T|F],UseISOFormat=[T|F]}
1118 begin
1119 Get_Open_Char;
1120 --Ada.Text_IO.Put_Line("Process RTF Footer");
1121 Get_Boolean ("UseDate" & (8..ARM_Input.Command_Name_Type'Last => ' '),
1122 Footer_Use_Date, Is_First => True);
1123 if Footer_Use_Date then
1124 Ada.Text_IO.Put_Line("RTF footer will include the date");
1125 else
1126 Ada.Text_IO.Put_Line("RTF footer will omit the date");
1127 end if;
1128
1129 Get_Boolean ("UseClauseName" & (14..ARM_Input.Command_Name_Type'Last => ' '),
1130 Footer_Use_Clause_Name);
1131 if Footer_Use_Clause_Name then
1132 Ada.Text_IO.Put_Line("RTF footer will include the name of the clause that starts the page");
1133 else
1134 Ada.Text_IO.Put_Line("RTF footer will include the fixed footer text");
1135 end if;
1136
1137 Get_Boolean ("UseISOFormat" & (13..ARM_Input.Command_Name_Type'Last => ' '),
1138 Footer_Use_ISO_Format);
1139 if Footer_Use_ISO_Format then
1140 Ada.Text_IO.Put_Line("RTF footer will use the ISO format (swiss font, multiple sizes)");
1141 else
1142 Ada.Text_IO.Put_Line("RTF footer will use the normal format (body fond, one size)");
1143 end if;
1144
1145 ARM_Input.Get_Char (Input_Object, Ch);
1146 if Ch = Close_Ch then
1147 null;
1148 else
1149 Ada.Text_IO.Put_Line ("** Missing closing character for command on line" & ARM_Input.Line_String (Input_Object));
1150 ARM_Input.Replace_Char (Input_Object);
1151 end if;
1152 end;
1153
1154 when RTF_Version_Name =>
1155 -- @RTFVersionName{Version=[<version>],Text=[<title_text>]}
1156 Process_Versioned_String (Version_Name);
1157
1158 when RTF_Page_Size =>
1159 -- @RTFPageSize{Letter|A4|HalfLetter|Ada95}
1160 declare
1161 Size : constant String :=
1162 Ada.Characters.Handling.To_Lower (Get_Single_String);
1163 begin
1164 if Size = "letter" then
1165 Page_Size := ARM_RTF.Letter;
1166 elsif Size = "a4" then
1167 Page_Size := ARM_RTF.A4;
1168 elsif Size = "halfletter" then
1169 Page_Size := ARM_RTF.Half_Letter;
1170 elsif Size = "ada95" then
1171 Page_Size := ARM_RTF.Ada95;
1172 else
1173 Ada.Text_IO.Put_Line ("** Unknown page size name: " & Size &
1174 " on line" & ARM_Input.Line_String (Input_Object));
1175 end if;
1176 Ada.Text_IO.Put_Line("RTF Page Size is " &
1177 ARM_RTF.Page_Size'Image(Page_Size));
1178 end;
1179
1180 when RTF_Fonts =>
1181 -- @RTFFonts{Serif=[Times|Souvenir]},SansSerif=[Arial|Helvetica]}
1182 Process_RTF_Fonts;
1183
1184 -- Source files:
1185
1186 when TOC =>
1187 -- @TOC
1188 if Source_Length = Source_Count'Last then
1189 Ada.Text_IO.Put_Line ("** Too many source files on line" & ARM_Input.Line_String (Input_Object));
1190 else
1191 Source_Length := Source_Length + 1;
1192 Source_Data(Source_Length) :=
1193 (Kind => TOC);
1194 end if;
1195
1196 when Source =>
1197 Process_Source_Command;
1198
1199 when Unknown =>
1200 Ada.Text_IO.Put_Line (" -- Unknown command (skipped) - " &
1201 Ada.Strings.Fixed.Trim (Command_Name, Ada.Strings.Right) &
1202 " on line " & ARM_Input.Line_String (Input_Object));
1203 end case;
1204 end Process_Command;
1205
1206 begin
1207 Reading_Loop: loop
1208 declare
1209 Char : Character;
1210 begin
1211 ARM_Input.Get_Char (Input_Object, Char);
1212 case Char is
1213 when '@' =>
1214 Process_Command;
1215 when Ascii.LF | ' ' =>
1216 null;
1217 when Ascii.SUB =>
1218 -- End of file.
1219 exit Reading_Loop;
1220 when others =>
1221 Ada.Text_IO.Put_Line ("** Character(s) not in a command in the master file on line" & ARM_Input.Line_String (Input_Object));
1222 while (Char /= ' ' and then Char /= '@' and then
1223 Char /= Ascii.LF and then Char /= Ascii.SUB) loop
1224 ARM_Input.Get_Char (Input_Object, Char);
1225 end loop;
1226 ARM_Input.Replace_Char (Input_Object);
1227 end case;
1228 end;
1229 end loop Reading_Loop;
1230
1231 -- Check for bad combinations:
1232 if ARM_Output."="(Font_of_Examples, ARM_Output.Roman) and then
1233 ARM_Output."="(Font_of_Body, ARM_Output.Swiss) then
1234 -- This doesn't work, since "Roman" examples use the
1235 -- body styles, and if they are Swiss...
1236 Ada.Text_IO.Put_Line (" ** Examples cannot be Roman if Body is Swiss!! (They will appear in the Swiss font)");
1237 end if;
1238 end Read_Master_File;
1239
1240
1241 procedure Create_Format (Format_Object : in out ARM_Format.Format_Type) is
1242 -- Create an appropriate format object.
1243 begin
1244 ARM_Format.Create (Format_Object, Change_Kind, Change_Version,
1245 Base_Change_Version => Base_Change_Version,
1246 Display_Index_Entries => Display_Index_Entries,
1247 Include_Annotations => Include_Annotations,
1248 Include_ISO => Include_ISO_Text,
1249 Link_Non_Terminals => Should_Link_Non_Terminals,
1250 Number_Paragraphs => Should_Number_Paragraphs,
1251 Examples_Font => Font_of_Examples,
1252 Use_ISO_2004_Note_Format => Use_ISO_2004_Note_Format,
1253 Use_ISO_2004_Contents_Format => Use_ISO_2004_Contents_Format,
1254 Use_ISO_2004_List_Format => Use_ISO_2004_List_Format,
1255 Top_Level_Subdivision_Name => Subdivision_Name_Kind);
1256 end Create_Format;
1257
1258
1259 procedure Scan_Sources is
1260 -- Run the scanning pass on the source files:
1261 Format_Object : ARM_Format.Format_Type;
1262 begin
1263 Create_Format (Format_Object);
1264 for Source_Index in Source_Data'First .. Source_Length loop
1265 case Source_Data(Source_Index).Kind is
1266 when TOC => null;
1267 when A_File =>
1268 ARM_Format.Scan (Format_Object,
1269 Source_Data(Source_Index).File_Name(1..Source_Data(Source_Index).File_Name_Len),
1270 Section_Number => Source_Data(Source_Index).Section_Number,
1271 Starts_New_Section => Source_Data(Source_Index).Starts_New_Section);
1272 when Empty => null;
1273 end case;
1274 end loop;
1275
1276 ARM_Format.Destroy (Format_Object);
1277 end Scan_Sources;
1278
1279
1280 procedure Generate_Sources (Output_Object : in out ARM_Output.Output_Type'Class) is
1281 -- Generate the results from the source files:
1282 Format_Object : ARM_Format.Format_Type;
1283 begin
1284 Create_Format (Format_Object);
1285
1286 for Source_Index in Source_Data'First .. Source_Length loop
1287 case Source_Data(Source_Index).Kind is
1288 when TOC =>
1289 ARM_Format.Write_Table_of_Contents (Format_Object, Output_Object);
1290 when A_File =>
1291 ARM_Format.Process (Format_Object,
1292 Source_Data(Source_Index).File_Name(1..Source_Data(Source_Index).File_Name_Len),
1293 Output_Object,
1294 Section_Name => Source_Data(Source_Index).Section_Name(1..Source_Data(Source_Index).Section_Name_Len),
1295 Section_Number => Source_Data(Source_Index).Section_Number,
1296 Starts_New_Section => Source_Data(Source_Index).Starts_New_Section);
1297 when Empty => null;
1298 end case;
1299 end loop;
1300
1301 ARM_Format.Destroy (Format_Object);
1302 end Generate_Sources;
1303
1304
1305 procedure Read_and_Process_Master_File (
1306 File_Name : in String;
1307 The_Change_Kind : ARM_Format.Change_Kind; -- Changes to generate.
1308 The_Change_Version : ARM_Contents.Change_Version_Type; -- Change version.
1309 The_Base_Change_Version : ARM_Contents.Change_Version_Type; -- Base change version.
1310 Output_Format : in Output_Format_Type;
1311 Output_Path : in String) is
1312 -- Read and process the master file given.
1313 Input_Object : ARM_File.File_Input_Type;
1314 begin
1315 Ada.Text_IO.Put_Line ("-- Reading master file " & File_Name);
1316 begin
1317 Arm_File.Open (Input_Object, File_Name);
1318 exception
1319 when others =>
1320 Ada.Text_IO.Put_Line ("** Unable to open master file " & File_Name);
1321 return;
1322 end;
1323
1324 Change_Kind := The_Change_Kind;
1325 Change_Version := The_Change_Version;
1326 Base_Change_Version := The_Base_Change_Version;
1327
1328 Source_Length := 0;
1329 Read_Master_File (Input_Object);
1330
1331 Ada.Text_IO.Put_Line (" Lines processed: " &
1332 ARM_File.Line_String (Input_Object));
1333 Arm_File.Close (Input_Object);
1334
1335 -- Now, execute the commands from the file.
1336
1337 Scan_Sources; -- Scanning pass.
1338
1339 -- Create the appropriate output object, then generate the results:
1340 case Output_Format is
1341 when HTML =>
1342 declare
1343 Output : ARM_HTML.HTML_Output_Type;
1344 begin
1345 ARM_HTML.Create (Output,
1346 Big_Files => Use_Large_HTML_Files,
1347 File_Prefix => +Output_File_Prefix,
1348 DOS_Filenames => Use_MS_DOS_Filenames,
1349 Output_Path => Output_Path,
1350 HTML_Kind => HTML_Kind,
1351 Use_Unicode => HTML_Use_Unicode,
1352 Number_Paragraphs => Should_Number_Paragraphs,
1353 Ref_URL => +HTML_Ref_URL,
1354 Srch_URL => +HTML_Srch_URL,
1355 Index_URL => +HTML_Index_URL,
1356 Use_Buttons => HTML_Use_Buttons,
1357 Nav_On_Top => HTML_Nav_On_Top,
1358 Nav_On_Bottom => HTML_Nav_On_Bottom,
1359 Tab_Emulation => HTML_Tab_Emulation,
1360 Script_HTML => +HTML_Script_Text,
1361 Header_HTML => +HTML_Header_Text,
1362 Footer_HTML => +HTML_Footer_Text,
1363 Title => Get_Versioned_String(Document_Title,Change_Version),
1364 Body_Font => Font_of_Body,
1365 Force_New_Revision_Colors => HTML_Use_New_Revision_Colors and then Change_Version >= '5',
1366 Text_Color => HTML_Text_Color,
1367 Background_Color => HTML_Background_Color,
1368 Link_Color => HTML_Link_Color,
1369 VLink_Color => HTML_VLink_Color,
1370 ALink_Color => HTML_ALink_Color);
1371 Generate_Sources (Output);
1372 ARM_HTML.Close (Output);
1373 end;
1374 when RTF =>
1375 declare
1376 Output : ARM_RTF.RTF_Output_Type;
1377 begin
1378 if ARM_Format."=" (Change_Kind, ARM_Format.Old_Only) or else
1379 Change_Version = '0' then
1380 ARM_RTF.Create (Output,
1381 Page_Size => Page_Size,
1382 Includes_Changes => False,
1383 Big_Files => Use_Large_RTF_Files,
1384 Output_Path => Output_Path,
1385 Primary_Serif_Font => Serif_Font,
1386 Primary_Sans_Serif_Font => Sans_Serif_Font,
1387 File_Prefix => +Output_File_Prefix,
1388 Title => Get_Versioned_String(Document_Title,Change_Version),
1389 Header_Prefix => Get_Versioned_String(Header_Prefix,Change_Version),
1390 Footer_Use_Date => Footer_Use_Date,
1391 Footer_Use_Clause_Name => Footer_Use_Clause_Name,
1392 Footer_Use_ISO_Format=> Footer_Use_ISO_Format,
1393 Footer_Text => Get_Versioned_String (Footer_Text, Change_Version),
1394 Body_Font => Font_of_Body,
1395 Version_Names => Version_Name);
1396 else
1397 ARM_RTF.Create (Output,
1398 Page_Size => Page_Size,
1399 Includes_Changes => True,
1400 Big_Files => Use_Large_RTF_Files,
1401 Output_Path => Output_Path,
1402 Primary_Serif_Font => Serif_Font,
1403 Primary_Sans_Serif_Font => Sans_Serif_Font,
1404 File_Prefix => +Output_File_Prefix,
1405 Title => Get_Versioned_String (Document_Title, Change_Version),
1406 Header_Prefix => Get_Versioned_String (Header_Prefix, Change_Version),
1407 Footer_Use_Date => Footer_Use_Date,
1408 Footer_Use_Clause_Name => Footer_Use_Clause_Name,
1409 Footer_Use_ISO_Format=> Footer_Use_ISO_Format,
1410 Footer_Text => Get_Versioned_String (Footer_Text, Change_Version),
1411 Body_Font => Font_of_Body,
1412 Version_Names => Version_Name);
1413 end if;
1414 Generate_Sources (Output);
1415 ARM_RTF.Close (Output);
1416 end;
1417 when Text =>
1418 declare
1419 Output : ARM_Text.Text_Output_Type;
1420 begin
1421 ARM_Text.Create (Output,
1422 File_Prefix => +Output_File_Prefix,
1423 Output_Path => Output_Path,
1424 Title => Get_Versioned_String (Document_Title, Change_Version));
1425 Generate_Sources (Output);
1426 ARM_Text.Close (Output);
1427 end;
1428 when Corr =>
1429 declare
1430 Output : ARM_Corr.Corr_Output_Type;
1431 begin
1432 ARM_Corr.Create (Output,
1433 File_Prefix => +Output_File_Prefix,
1434 Output_Path => Output_Path,
1435 Title => Get_Versioned_String (Document_Title, Change_Version));
1436 Generate_Sources (Output);
1437 ARM_Corr.Close (Output);
1438 end;
1439 when Info =>
1440 declare
1441 Output : ARM_TexInfo.Texinfo_Output_Type;
1442 begin
1443 ARM_TexInfo.Create (Output,
1444 File_Prefix => +Output_File_Prefix,
1445 Output_Path => Output_Path,
1446 Change_Version => Change_Version,
1447 Title => Get_Versioned_String (Document_Title, Change_Version));
1448 Generate_Sources (Output);
1449 ARM_TexInfo.Close (Output);
1450 end;
1451 end case;
1452
1453 end Read_and_Process_Master_File;
1454
1455
1456 end ARM_Master;