annotate gcc/ada/libgnat/a-tigeau.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . T E X T _ I O . G E N E R I C _ A U X --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package contains a set of auxiliary routines used by the Text_IO
kono
parents:
diff changeset
33 -- generic children, including for reading and writing numeric strings.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 private package Ada.Text_IO.Generic_Aux is
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 -- Note: for all the Load routines, File indicates the file to be read,
kono
parents:
diff changeset
38 -- Buf is the string into which data is stored, Ptr is the index of the
kono
parents:
diff changeset
39 -- last character stored so far, and is updated if additional characters
kono
parents:
diff changeset
40 -- are stored. Data_Error is raised if the input overflows Buf. The only
kono
parents:
diff changeset
41 -- Load routines that do a file status check are Load_Skip and Load_Width
kono
parents:
diff changeset
42 -- so one of these two routines must be called first.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 procedure Check_End_Of_Field
kono
parents:
diff changeset
45 (Buf : String;
kono
parents:
diff changeset
46 Stop : Integer;
kono
parents:
diff changeset
47 Ptr : Integer;
kono
parents:
diff changeset
48 Width : Field);
kono
parents:
diff changeset
49 -- This routine is used after doing a get operations on a numeric value.
kono
parents:
diff changeset
50 -- Buf is the string being scanned, and Stop is the last character of
kono
parents:
diff changeset
51 -- the field being scanned. Ptr is as set by the call to the scan routine
kono
parents:
diff changeset
52 -- that scanned out the numeric value, i.e. it points one past the last
kono
parents:
diff changeset
53 -- character scanned, and Width is the width parameter from the Get call.
kono
parents:
diff changeset
54 --
kono
parents:
diff changeset
55 -- There are two cases, if Width is non-zero, then a check is made that
kono
parents:
diff changeset
56 -- the remainder of the field is all blanks. If Width is zero, then it
kono
parents:
diff changeset
57 -- means that the scan routine scanned out only part of the field. We
kono
parents:
diff changeset
58 -- have already scanned out the field that the ACVC tests seem to expect
kono
parents:
diff changeset
59 -- us to read (even if it does not follow the syntax of the type being
kono
parents:
diff changeset
60 -- scanned, e.g. allowing negative exponents in integers, and underscores
kono
parents:
diff changeset
61 -- at the end of the string), so we just raise Data_Error.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 procedure Check_On_One_Line (File : File_Type; Length : Integer);
kono
parents:
diff changeset
64 -- Check to see if item of length Integer characters can fit on
kono
parents:
diff changeset
65 -- current line. Call New_Line if not, first checking that the
kono
parents:
diff changeset
66 -- line length can accommodate Length characters, raise Layout_Error
kono
parents:
diff changeset
67 -- if item is too large for a single line.
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 function Getc (File : File_Type) return Integer;
kono
parents:
diff changeset
70 -- Gets next character from file, which has already been checked for
kono
parents:
diff changeset
71 -- being in read status, and returns the character read if no error
kono
parents:
diff changeset
72 -- occurs. The result is EOF if the end of file was read. Note that
kono
parents:
diff changeset
73 -- the Col value is not bumped, so it is the caller's responsibility
kono
parents:
diff changeset
74 -- to bump it if necessary.
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Is_Blank (C : Character) return Boolean;
kono
parents:
diff changeset
77 -- Determines if C is a blank (space or tab)
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 procedure Load_Width
kono
parents:
diff changeset
80 (File : File_Type;
kono
parents:
diff changeset
81 Width : Field;
kono
parents:
diff changeset
82 Buf : out String;
kono
parents:
diff changeset
83 Ptr : in out Integer);
kono
parents:
diff changeset
84 -- Loads exactly Width characters, unless a line mark is encountered first
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Load_Skip (File : File_Type);
kono
parents:
diff changeset
87 -- Skips leading blanks and line and page marks, if the end of file is
kono
parents:
diff changeset
88 -- read without finding a non-blank character, then End_Error is raised.
kono
parents:
diff changeset
89 -- Note: a blank is defined as a space or horizontal tab (RM A.10.6(5)).
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 procedure Load
kono
parents:
diff changeset
92 (File : File_Type;
kono
parents:
diff changeset
93 Buf : out String;
kono
parents:
diff changeset
94 Ptr : in out Integer;
kono
parents:
diff changeset
95 Char : Character;
kono
parents:
diff changeset
96 Loaded : out Boolean);
kono
parents:
diff changeset
97 -- If next character is Char, loads it, otherwise no characters are loaded
kono
parents:
diff changeset
98 -- Loaded is set to indicate whether or not the character was found.
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 procedure Load
kono
parents:
diff changeset
101 (File : File_Type;
kono
parents:
diff changeset
102 Buf : out String;
kono
parents:
diff changeset
103 Ptr : in out Integer;
kono
parents:
diff changeset
104 Char : Character);
kono
parents:
diff changeset
105 -- Same as above, but no indication if character is loaded
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Load
kono
parents:
diff changeset
108 (File : File_Type;
kono
parents:
diff changeset
109 Buf : out String;
kono
parents:
diff changeset
110 Ptr : in out Integer;
kono
parents:
diff changeset
111 Char1 : Character;
kono
parents:
diff changeset
112 Char2 : Character;
kono
parents:
diff changeset
113 Loaded : out Boolean);
kono
parents:
diff changeset
114 -- If next character is Char1 or Char2, loads it, otherwise no characters
kono
parents:
diff changeset
115 -- are loaded. Loaded is set to indicate whether or not one of the two
kono
parents:
diff changeset
116 -- characters was found.
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Load
kono
parents:
diff changeset
119 (File : File_Type;
kono
parents:
diff changeset
120 Buf : out String;
kono
parents:
diff changeset
121 Ptr : in out Integer;
kono
parents:
diff changeset
122 Char1 : Character;
kono
parents:
diff changeset
123 Char2 : Character);
kono
parents:
diff changeset
124 -- Same as above, but no indication if character is loaded
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 procedure Load_Digits
kono
parents:
diff changeset
127 (File : File_Type;
kono
parents:
diff changeset
128 Buf : out String;
kono
parents:
diff changeset
129 Ptr : in out Integer;
kono
parents:
diff changeset
130 Loaded : out Boolean);
kono
parents:
diff changeset
131 -- Loads a sequence of zero or more decimal digits. Loaded is set if
kono
parents:
diff changeset
132 -- at least one digit is loaded.
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 procedure Load_Digits
kono
parents:
diff changeset
135 (File : File_Type;
kono
parents:
diff changeset
136 Buf : out String;
kono
parents:
diff changeset
137 Ptr : in out Integer);
kono
parents:
diff changeset
138 -- Same as above, but no indication if character is loaded
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 procedure Load_Extended_Digits
kono
parents:
diff changeset
141 (File : File_Type;
kono
parents:
diff changeset
142 Buf : out String;
kono
parents:
diff changeset
143 Ptr : in out Integer;
kono
parents:
diff changeset
144 Loaded : out Boolean);
kono
parents:
diff changeset
145 -- Like Load_Digits, but also allows extended digits a-f and A-F
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 procedure Load_Extended_Digits
kono
parents:
diff changeset
148 (File : File_Type;
kono
parents:
diff changeset
149 Buf : out String;
kono
parents:
diff changeset
150 Ptr : in out Integer);
kono
parents:
diff changeset
151 -- Same as above, but no indication if character is loaded
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 function Nextc (File : File_Type) return Integer;
kono
parents:
diff changeset
154 -- Like Getc, but includes a call to Ungetc, so that the file
kono
parents:
diff changeset
155 -- pointer is not moved by the call.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 procedure Put_Item (File : File_Type; Str : String);
kono
parents:
diff changeset
158 -- This routine is like Text_IO.Put, except that it checks for overflow
kono
parents:
diff changeset
159 -- of bounded lines, as described in (RM A.10.6(8)). It is used for
kono
parents:
diff changeset
160 -- all output of numeric values and of enumeration values.
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 procedure Store_Char
kono
parents:
diff changeset
163 (File : File_Type;
kono
parents:
diff changeset
164 ch : Integer;
kono
parents:
diff changeset
165 Buf : in out String;
kono
parents:
diff changeset
166 Ptr : in out Integer);
kono
parents:
diff changeset
167 -- Store a single character in buffer, checking for overflow and
kono
parents:
diff changeset
168 -- adjusting the column number in the file to reflect the fact
kono
parents:
diff changeset
169 -- that a character has been acquired from the input stream. If
kono
parents:
diff changeset
170 -- the character will not fit in the buffer it is stored in the
kono
parents:
diff changeset
171 -- last character position of the buffer and Ptr is unchanged.
kono
parents:
diff changeset
172 -- No exception is raised in this case, it is the caller's job
kono
parents:
diff changeset
173 -- to raise Data_Error if the buffer fills up, so typically the
kono
parents:
diff changeset
174 -- caller will make the buffer one character longer than needed.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 procedure String_Skip (Str : String; Ptr : out Integer);
kono
parents:
diff changeset
177 -- Used in the Get from string procedures to skip leading blanks in the
kono
parents:
diff changeset
178 -- string. Ptr is set to the index of the first non-blank. If the string
kono
parents:
diff changeset
179 -- is all blanks, then the exception End_Error is raised, Note that blank
kono
parents:
diff changeset
180 -- is defined as a space or horizontal tab (RM A.10.6(5)).
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 procedure Ungetc (ch : Integer; File : File_Type);
kono
parents:
diff changeset
183 -- Pushes back character into stream, using ungetc. The caller has
kono
parents:
diff changeset
184 -- checked that the file is in read status. Device_Error is raised
kono
parents:
diff changeset
185 -- if the character cannot be pushed back. An attempt to push back
kono
parents:
diff changeset
186 -- an end of file (EOF) is ignored.
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 private
kono
parents:
diff changeset
189 pragma Inline (Is_Blank);
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 end Ada.Text_IO.Generic_Aux;