Debian Codegraph @

progs/arm_corr.ads

raw
1 with ARM_Output,
2 ARM_Contents,
3 Ada.Text_IO;
4 package ARM_Corr is
5
6 --
7 -- Ada reference manual formatter (ARM_Form).
8 --
9 -- This package defines the text output object.
10 -- Output objects are responsible for implementing the details of
11 -- a particular format.
12 --
13 -- ---------------------------------------
14 -- Copyright 2000, 2002, 2004, 2005, 2006, 2007, 2011, 2012
15 -- AXE Consultants. All rights reserved.
16 -- P.O. Box 1512, Madison WI 53701
17 -- E-Mail: [email protected]
18 --
19 -- ARM_Form is free software: you can redistribute it and/or modify
20 -- it under the terms of the GNU General Public License version 3
21 -- as published by the Free Software Foundation.
22 --
23 -- AXE CONSULTANTS MAKES THIS TOOL AND SOURCE CODE AVAILABLE ON AN "AS IS"
24 -- BASIS AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY,
25 -- CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR FUNCTIONING OF THIS TOOL.
26 -- IN NO EVENT WILL AXE CONSULTANTS BE LIABLE FOR ANY GENERAL,
27 -- CONSEQUENTIAL, INDIRECT, INCIDENTAL, EXEMPLARY, OR SPECIAL DAMAGES,
28 -- EVEN IF AXE CONSULTANTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
29 -- DAMAGES.
30 --
31 -- A copy of the GNU General Public License is available in the file
32 -- gpl-3-0.txt in the standard distribution of the ARM_Form tool.
33 -- Otherwise, see <http://www.gnu.org/licenses/>.
34 --
35 -- If the GPLv3 license is not satisfactory for your needs, a commercial
36 -- use license is available for this tool. Contact Randy at AXE Consultants
37 -- for more information.
38 --
39 -- ---------------------------------------
40 --
41 -- Edit History:
42 --
43 -- 6/ 2/05 - RLB - Created base package from text and HTML versions.
44 -- 1/11/06 - RLB - Eliminated dispatching Create in favor of tailored
45 -- versions.
46 -- 1/13/06 - RLB - Added new Link operations.
47 -- 2/ 8/06 - RLB - Added additional parameters to the table command.
48 -- 2/10/06 - RLB - Added even more additional parameters to the
49 -- table command.
50 -- - RLB - Added picture command.
51 -- 9/25/06 - RLB - Added Last_Column_Width to Start_Table.
52 -- 10/13/06 - RLB - Added Local_Link_Start and Local_Link_End to allow
53 -- formatting in the linked text.
54 -- 2/ 9/07 - RLB - Changed comments on AI_Reference.
55 -- 2/13/07 - RLB - Revised to separate style and indent information
56 -- for paragraphs.
57 -- 12/19/07 - RLB - Added limited colors to Text_Format.
58 -- 10/18/11 - RLB - Changed to GPLv3 license.
59 -- 10/25/11 - RLB - Added old insertion version to Revised_Clause_Header.
60 -- 8/31/12 - RLB - Added Output_Path.
61 -- 11/26/12 - RLB - Added subdivision names to Clause_Header and
62 -- Revised_Clause_Header.
63
64 type Corr_Output_Type is new ARM_Output.Output_Type with private;
65
66 procedure Create (Output_Object : in out Corr_Output_Type;
67 File_Prefix : in String;
68 Output_Path : in String;
69 Title : in String := "");
70 -- Create an Output_Object for a document.
71 -- The prefix of the output file names is File_Prefix - this
72 -- should be no more then 5 characters allowed in file names.
73 -- The result files will be written to Output_Path.
74 -- The title of the document is Title.
75
76 procedure Close (Output_Object : in out Corr_Output_Type);
77 -- Close an Output_Object. No further output to the object is
78 -- allowed after this call.
79
80
81 procedure Section (Output_Object : in out Corr_Output_Type;
82 Section_Title : in String;
83 Section_Name : in String);
84 -- Start a new section. The title is Section_Title (this is
85 -- intended for humans). The name is Section_Name (this is
86 -- intended to be suitable to be a portion of a file name).
87
88 procedure Set_Columns (Output_Object : in out Corr_Output_Type;
89 Number_of_Columns : in ARM_Output.Column_Count);
90 -- Set the number of columns.
91 -- Raises Not_Valid_Error if in a paragraph.
92
93 procedure Start_Paragraph (Output_Object : in out Corr_Output_Type;
94 Style : in ARM_Output.Paragraph_Style_Type;
95 Indent : in ARM_Output.Paragraph_Indent_Type;
96 Number : in String;
97 No_Prefix : in Boolean := False;
98 Tab_Stops : in ARM_Output.Tab_Info := ARM_Output.NO_TABS;
99 No_Breaks : in Boolean := False;
100 Keep_with_Next : in Boolean := False;
101 Space_After : in ARM_Output.Space_After_Type
102 := ARM_Output.Normal;
103 Justification : in ARM_Output.Justification_Type
104 := ARM_Output.Default);
105 -- Start a new paragraph. The style and indent of the paragraph is as
106 -- specified. The (AA)RM paragraph number (which might include update
107 -- and version numbers as well: [12.1/1]) is Number. If the format is
108 -- a type with a prefix (bullets, hangining items), the prefix is
109 -- omitted if No_Prefix is true. Tab_Stops defines the tab stops for
110 -- the paragraph. If No_Breaks is True, we will try to avoid page breaks
111 -- in the paragraph. If Keep_with_Next is true, we will try to avoid
112 -- separating this paragraph and the next one. (These may have no
113 -- effect in formats that don't have page breaks). Space_After
114 -- specifies the amount of space following the paragraph. Justification
115 -- specifies the text justification for the paragraph. Not_Valid_Error
116 -- is raised if Tab_Stops /= NO_TABS for a hanging or bulleted format.
117
118 procedure End_Paragraph (Output_Object : in out Corr_Output_Type);
119 -- End a paragraph.
120
121 procedure Category_Header (Output_Object : in out Corr_Output_Type;
122 Header_Text : String);
123 -- Output a Category header (that is, "Legality Rules",
124 -- "Dynamic Semantics", etc.)
125 -- (Note: We did not use a enumeration here to insure that these
126 -- headers are spelled the same in all output versions).
127 -- Raises Not_Valid_Error if in a paragraph.
128
129 procedure Clause_Header (Output_Object : in out Corr_Output_Type;
130 Header_Text : in String;
131 Level : in ARM_Contents.Level_Type;
132 Clause_Number : in String;
133 Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind;
134 No_Page_Break : in Boolean := False);
135 -- Output a Clause header. The level of the header is specified
136 -- in Level. The Clause Number is as specified; the top-level (and
137 -- other) subdivision names are as specified. These should appear in
138 -- the table of contents.
139 -- For hyperlinked formats, this should generate a link target.
140 -- If No_Page_Break is True, suppress any page breaks.
141 -- Raises Not_Valid_Error if in a paragraph.
142
143 procedure Revised_Clause_Header
144 (Output_Object : in out Corr_Output_Type;
145 New_Header_Text : in String;
146 Old_Header_Text : in String;
147 Level : in ARM_Contents.Level_Type;
148 Clause_Number : in String;
149 Version : in ARM_Contents.Change_Version_Type;
150 Old_Version : in ARM_Contents.Change_Version_Type;
151 Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind;
152 No_Page_Break : in Boolean := False);
153 -- Output a revised clause header. Both the original and new text will
154 -- be output. The level of the header is specified in Level. The Clause
155 -- Number is as specified; the top-level (and other) subdivision names
156 -- are as specified. These should appear in the table of contents.
157 -- For hyperlinked formats, this should generate a link target.
158 -- Version is the insertion version of the new text; Old_Version is
159 -- the insertion version of the old text.
160 -- If No_Page_Break is True, suppress any page breaks.
161 -- Raises Not_Valid_Error if in a paragraph.
162
163 procedure TOC_Marker (Output_Object : in out Corr_Output_Type;
164 For_Start : in Boolean);
165 -- Mark the start (if For_Start is True) or end (if For_Start is
166 -- False) of the table of contents data. Output objects that
167 -- auto-generate the table of contents can use this to do needed
168 -- actions.
169
170 procedure New_Page (Output_Object : in out Corr_Output_Type;
171 Kind : ARM_Output.Page_Kind_Type := ARM_Output.Any_Page);
172 -- Output a page break.
173 -- Note that this has no effect on non-printing formats.
174 -- Any_Page breaks to the top of the next page (whatever it is);
175 -- Odd_Page_Only breaks to the top of the odd-numbered page;
176 -- Soft_Page allows a page break but does not force one (use in
177 -- "No_Breaks" paragraphs.)
178 -- Raises Not_Valid_Error if in a paragraph if Kind = Any_Page or
179 -- Odd_Page, and if not in a paragraph if Kind = Soft_Page.
180
181 procedure New_Column (Output_Object : in out Corr_Output_Type);
182 -- Output a column break.
183 -- Raises Not_Valid_Error if in a paragraph, or if the number of
184 -- columns is 1.
185
186 procedure Separator_Line (Output_Object : in out Corr_Output_Type;
187 Is_Thin : Boolean := True);
188 -- Output a separator line. It is thin if "Is_Thin" is true.
189 -- Raises Not_Valid_Error if in a paragraph.
190
191 procedure Start_Table (Output_Object : in out Corr_Output_Type;
192 Columns : in ARM_Output.Column_Count;
193 First_Column_Width : in ARM_Output.Column_Count;
194 Last_Column_Width : in ARM_Output.Column_Count;
195 Alignment : in ARM_Output.Column_Text_Alignment;
196 No_Page_Break : in Boolean;
197 Has_Border : in Boolean;
198 Small_Text_Size : in Boolean;
199 Header_Kind : in ARM_Output.Header_Kind_Type);
200 -- Starts a table. The number of columns is Columns; the first
201 -- column has First_Column_Width times the normal column width, and
202 -- the last column has Last_Column_Width times the normal column width.
203 -- Alignment is the horizontal text alignment within the columns.
204 -- No_Page_Break should be True to keep the table intact on a single
205 -- page; False to allow it to be split across pages.
206 -- Has_Border should be true if a border is desired, false otherwise.
207 -- Small_Text_Size means that the contents will have the AARM size;
208 -- otherwise it will have the normal size.
209 -- Header_Kind determines whether the table has headers.
210 -- This command starts a paragraph; the entire table is a single
211 -- paragraph. Text will be considered part of the caption until the
212 -- next table marker call.
213 -- Raises Not_Valid_Error if in a paragraph.
214
215 procedure Table_Marker (Output_Object : in out Corr_Output_Type;
216 Marker : in ARM_Output.Table_Marker_Type);
217 -- Marks the end of an entity in a table.
218 -- If Marker is End_Caption, the table caption ends and the
219 -- future text is part of the table header.
220 -- If Marker is End_Header, the table header ends and the
221 -- future text is part of the table body.
222 -- If Marker is End_Row, a row in the table is completed, and another
223 -- row started.
224 -- If Marker is End_Item, an item in the table header or body is ended,
225 -- and another started.
226 -- If Marker is End_Table, the entire table is finished.
227 -- Raises Not_Valid_Error if not in a table.
228
229 -- Text output: These are only allowed after a Start_Paragraph and
230 -- before any End_Paragraph. Raises Not_Valid_Error if not allowed.
231
232 procedure Ordinary_Text (Output_Object : in out Corr_Output_Type;
233 Text : in String);
234 -- Output ordinary text.
235 -- The text must end at a word break, never in the middle of a word.
236
237 procedure Ordinary_Character (Output_Object : in out Corr_Output_Type;
238 Char : in Character);
239 -- Output an ordinary character.
240 -- Spaces will be used to break lines as needed.
241
242 procedure Hard_Space (Output_Object : in out Corr_Output_Type);
243 -- Output a hard space. No line break should happen at a hard space.
244
245 procedure Line_Break (Output_Object : in out Corr_Output_Type);
246 -- Output a line break. This does not start a new paragraph.
247 -- This corresponds to a "<BR>" in HTML.
248
249 procedure Index_Line_Break (Output_Object : in out Corr_Output_Type;
250 Clear_Keep_with_Next : in Boolean);
251 -- Output a line break for the index. This does not start a new
252 -- paragraph in terms of spacing. This corresponds to a "<BR>"
253 -- in HTML. If Clear_Keep_with_Next is true, insure that the next
254 -- line does not require the following line to stay with it.
255
256 procedure Soft_Line_Break (Output_Object : in out Corr_Output_Type);
257 -- Output a soft line break. This is a place (in the middle of a
258 -- "word") that we allow a line break. It is usually used after
259 -- underscores in long non-terminals.
260
261 procedure Soft_Hyphen_Break (Output_Object : in out Corr_Output_Type);
262 -- Output a soft line break, with a hyphen. This is a place (in the middle of
263 -- a "word") that we allow a line break. If the line break is used,
264 -- a hyphen will be added to the text.
265
266 procedure Tab (Output_Object : in out Corr_Output_Type);
267 -- Output a tab, inserting space up to the next tab stop.
268 -- Raises Not_Valid_Error if the paragraph was created with
269 -- Tab_Stops = ARM_Output.NO_TABS.
270
271 procedure Special_Character (Output_Object : in out Corr_Output_Type;
272 Char : in ARM_Output.Special_Character_Type);
273 -- Output an special character.
274
275 procedure Unicode_Character (Output_Object : in out Corr_Output_Type;
276 Char : in ARM_Output.Unicode_Type);
277 -- Output a Unicode character, with code position Char.
278
279 procedure End_Hang_Item (Output_Object : in out Corr_Output_Type);
280 -- Marks the end of a hanging item. Call only once per paragraph.
281 -- Raises Not_Valid_Error if the paragraph style is not in
282 -- Text_Prefixed_Style_Subtype, or if this has already been
283 -- called for the current paragraph, or if the paragraph was started
284 -- with No_Prefix = True.
285
286 procedure Text_Format (Output_Object : in out Corr_Output_Type;
287 Format : in ARM_Output.Format_Type);
288 -- Change the text format so that all of the properties are as specified.
289 -- Note: Changes to these properties ought be stack-like; that is,
290 -- Bold on, Italic on, Italic off, Bold off is OK; Bold on, Italic on,
291 -- Bold off, Italic off should be avoided (as separate commands).
292
293 procedure Clause_Reference (Output_Object : in out Corr_Output_Type;
294 Text : in String;
295 Clause_Number : in String);
296 -- Generate a reference to a clause in the standard. The text of
297 -- the reference is "Text", and the number of the clause is
298 -- Clause_Number. For hyperlinked formats, this should generate
299 -- a link; for other formats, the text alone is generated.
300
301 procedure Index_Target (Output_Object : in out Corr_Output_Type;
302 Index_Key : in Natural);
303 -- Generate a index target. This marks the location where an index
304 -- reference occurs. Index_Key names the index item involved.
305 -- For hyperlinked formats, this should generate a link target;
306 -- for other formats, nothing is generated.
307
308 procedure Index_Reference (Output_Object : in out Corr_Output_Type;
309 Text : in String;
310 Index_Key : in Natural;
311 Clause_Number : in String);
312 -- Generate a reference to an index target in the standard. The text
313 -- of the reference is "Text", and Index_Key and Clause_Number denotes
314 -- the target. For hyperlinked formats, this should generate
315 -- a link; for other formats, the text alone is generated.
316
317 procedure DR_Reference (Output_Object : in out Corr_Output_Type;
318 Text : in String;
319 DR_Number : in String);
320 -- Generate a reference to an DR from the standard. The text
321 -- of the reference is "Text", and DR_Number denotes
322 -- the target. For hyperlinked formats, this should generate
323 -- a link; for other formats, the text alone is generated.
324
325 procedure AI_Reference (Output_Object : in out Corr_Output_Type;
326 Text : in String;
327 AI_Number : in String);
328 -- Generate a reference to an AI from the standard. The text
329 -- of the reference is "Text", and AI_Number denotes
330 -- the target (in unfolded format). For hyperlinked formats, this should
331 -- generate a link; for other formats, the text alone is generated.
332
333 procedure Local_Target (Output_Object : in out Corr_Output_Type;
334 Text : in String;
335 Target : in String);
336 -- Generate a local target. This marks the potential target of local
337 -- links identified by "Target". Text is the text of the target.
338 -- For hyperlinked formats, this should generate a link target;
339 -- for other formats, only the text is generated.
340
341 procedure Local_Link (Output_Object : in out Corr_Output_Type;
342 Text : in String;
343 Target : in String;
344 Clause_Number : in String);
345 -- Generate a local link to the target and clause given.
346 -- Text is the text of the link.
347 -- For hyperlinked formats, this should generate a link;
348 -- for other formats, only the text is generated.
349
350 procedure Local_Link_Start (Output_Object : in out Corr_Output_Type;
351 Target : in String;
352 Clause_Number : in String);
353 -- Generate a local link to the target and clause given.
354 -- The link will surround text until Local_Link_End is called.
355 -- Local_Link_End must be called before this routine can be used again.
356 -- For hyperlinked formats, this should generate a link;
357 -- for other formats, only the text is generated.
358
359 procedure Local_Link_End (Output_Object : in out Corr_Output_Type;
360 Target : in String;
361 Clause_Number : in String);
362 -- End a local link for the target and clause given.
363 -- This must be in the same paragraph as the Local_Link_Start.
364 -- For hyperlinked formats, this should generate a link;
365 -- for other formats, only the text is generated.
366
367 procedure URL_Link (Output_Object : in out Corr_Output_Type;
368 Text : in String;
369 URL : in String);
370 -- Generate a link to the URL given.
371 -- Text is the text of the link.
372 -- For hyperlinked formats, this should generate a link;
373 -- for other formats, only the text is generated.
374
375 procedure Picture (Output_Object : in out Corr_Output_Type;
376 Name : in String;
377 Descr : in String;
378 Alignment : in ARM_Output.Picture_Alignment;
379 Height, Width : in Natural;
380 Border : in ARM_Output.Border_Kind);
381 -- Generate a picture.
382 -- Name is the (simple) file name of the picture; Descr is a
383 -- descriptive name for the picture (it will appear in some web
384 -- browsers).
385 -- We assume that it is a .GIF or .JPG and that it will be present
386 -- in the same directory as the output files.
387 -- Alignment specifies the picture alignment.
388 -- Height and Width specify the picture size in pixels.
389 -- Border specifies the kind of border.
390
391 private
392
393 subtype Buffer_String is String (1 .. 120);
394 subtype Prefix_String is String(1..5);
395 subtype Clause_String is String(1..20);
396 type Corr_Output_Type is new ARM_Output.Output_Type with record
397 Is_Valid : Boolean := False;
398 Is_In_Paragraph : Boolean := False;
399 Is_In_Table : Boolean := False; -- Are we processing a table?
400 Is_Hanging : Boolean := False; -- If we are in a paragraph,
401 -- is it a hanging paragraph?
402 Saw_Hang_End : Boolean := False; -- If we are in a hanging paragraph,
403 -- have we seen the end of the hanging part yet?
404 Output_Buffer : Buffer_String; -- Output buffer to make smarter breaks.
405 Output_Buffer_Len : Natural := 0; -- This should be empty between paragraphs.
406 -- The idea is that the buffer is always logically
407 -- preceeded by a space. Thus it is always OK to
408 -- move the text in the buffer to the next line.
409 Output_Buffer_Space_Before : Boolean := False;
410 -- Do we need to output a space before the buffer?
411 Output_File : Ada.Text_IO.File_Type;
412 Output_Path : Buffer_String;
413 Output_Path_Len : Natural := 0;
414 File_Prefix : Prefix_String; -- Blank padded.
415 Char_Count : Natural := 0; -- Characters on current line.
416 Out_Char_Count : Natural := 0; -- Characters output on current line.
417 Indent_Amount : Natural := 0; -- Amount to indent paragraphs.
418 Para_Style : ARM_Output.Paragraph_Style_Type := ARM_Output.Normal;
419 Para_Indent : ARM_Output.Paragraph_Indent_Type := 0; -- Specified indent.
420 Is_Fixed_Format : Boolean; -- Is the text currently in a fixed format? (@Xcode)
421 Is_Bold : Boolean; -- Is the text currently bold?
422 Is_Italic : Boolean; -- Is the text current italics?
423 Font : ARM_Output.Font_Family_Type; -- What is the current font family?
424 Size : ARM_Output.Size_Type; -- What is the current relative size?
425 Change : ARM_Output.Change_Type := ARM_Output.None;
426 Location : ARM_Output.Location_Type := ARM_Output.Normal;
427 Tab_Stops : ARM_Output.Tab_Info := ARM_Output.NO_TABS;
428 Clause_Num : Clause_String; -- The number of the current clause
429 Clause_Len : Natural := 0;
430 end record;
431
432 end ARM_Corr;