Debian Codegraph @

progs/arm_file.ads

raw
1 with ARM_Input,
2 Ada.Text_IO;
3 package ARM_File is
4
5 --
6 -- Ada reference manual formatter (ARM_Form).
7 --
8 -- This package contains the definition of reading an input file.
9 --
10 -- ---------------------------------------
11 -- Copyright 2000, 2011, 2019
12 -- AXE Consultants. All rights reserved.
13 -- P.O. Box 1512, Madison WI 53704
14 -- E-Mail: [email protected]
15 --
16 -- ARM_Form is free software: you can redistribute it and/or modify
17 -- it under the terms of the GNU General Public License version 3
18 -- as published by the Free Software Foundation.
19 --
20 -- AXE CONSULTANTS MAKES THIS TOOL AND SOURCE CODE AVAILABLE ON AN "AS IS"
21 -- BASIS AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE ACCURACY,
22 -- CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR FUNCTIONING OF THIS TOOL.
23 -- IN NO EVENT WILL AXE CONSULTANTS BE LIABLE FOR ANY GENERAL,
24 -- CONSEQUENTIAL, INDIRECT, INCIDENTAL, EXEMPLARY, OR SPECIAL DAMAGES,
25 -- EVEN IF AXE CONSULTANTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
26 -- DAMAGES.
27 --
28 -- A copy of the GNU General Public License is available in the file
29 -- gpl-3-0.txt in the standard distribution of the ARM_Form tool.
30 -- Otherwise, see <http://www.gnu.org/licenses/>.
31 --
32 -- If the GPLv3 license is not satisfactory for your needs, a commercial
33 -- use license is available for this tool. Contact Randy at AXE Consultants
34 -- for more information.
35 --
36 -- ---------------------------------------
37 --
38 -- Edit History:
39 --
40 -- 5/15/00 - RLB - Created package.
41 -- 10/18/11 - RLB - Changed to GPLv3 license.
42 -- 2/15/19 - RLB - Added Recording_Start_Line to help debugging.
43 -- 2/19/19 - RLB - Added Extra_LF so we can put back the line end of
44 -- the previous line.
45
46 type File_Input_Type is new ARM_Input.Input_Type with private;
47
48 procedure Open (Input_Object : in out File_Input_Type;
49 File_Name : in String);
50 -- Open an input object for a file.
51 -- This may propagate file exceptions.
52
53 procedure Close (Input_Object : in out File_Input_Type);
54 -- Close the input object (entity).
55 -- May propagate exceptions from the underlying implementation
56 -- (that is, I/O exceptions).
57
58 procedure Get_Char (Input_Object : in out File_Input_Type;
59 Char : out Character);
60 -- We represent end of line by Ascii.LF.
61 -- Raises: End_Error when the end of file is reached.
62 -- Not_Valid_Error if Input_Object is not valid (open).
63
64 procedure Replace_Char (Input_Object : in out File_Input_Type);
65 -- Replaces the last character read (with Get_Char); the next call
66 -- to Get_Char will return it.
67 -- Raises: Not_Valid_Error if Input_Object is not valid (open).
68
69 function Line_String (Input_Object : in File_Input_Type) return String;
70 -- Returns a string representing the line number and entity.
71 -- Usually used in error messages.
72 -- Raises: Not_Valid_Error if Input_Object is not valid (open).
73
74 procedure Start_Recording (Input_Object : in out File_Input_Type);
75 -- Start recording all characters read into a local buffer.
76 -- Use this when text needs to be formatted into the output
77 -- file *and* be saved for future use.
78 -- Raises: Not_Valid_Error if Input_Object is not valid (open).
79
80 procedure Stop_Recording_and_Read_Result
81 (Input_Object : in out File_Input_Type; Result : out String;
82 Len : out Natural);
83 -- Stop recording characters read. Put the result into Result,
84 -- and the number of characters written into Len.
85 -- Raises: Not_Valid_Error if Input_Object is not valid (open).
86
87 private
88 type File_Input_Type is new ARM_Input.Input_Type with record
89 Is_Valid : Boolean := False;
90 Fyle : Ada.Text_IO.File_Type;
91 Line_Counter : Natural := 0;
92 Buffer : String(1..250);
93 Buffer_Last : Natural := 0;
94 Buffer_Index : Natural := 0; -- Last character read from buffer.
95 Extra_LF : Boolean := False;
96 -- For recording:
97 Recording : Boolean := False;
98 Recording_Buffer : String(1..ARM_Input.MAX_RECORDING_SIZE);
99 Recording_Len : Natural := 0;
100 Recording_Start_Line : Natural := 0;
101 -- Name:
102 Name : String(1..120);
103 Name_Len : Natural;
104 end record;
105 end ARM_File;