1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . E N U M E R A T I O N _ A U X --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
11 -- GNAT 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. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Ada.Text_IO.Generic_Aux; use Ada.Text_IO.Generic_Aux;
35 with Ada.Characters.Handling; use Ada.Characters.Handling;
37 -- Note: this package does not yet deal properly with wide characters ???
39 package body Ada.Text_IO.Enumeration_Aux is
45 procedure Get_Enum_Lit
57 C := Character'Val (ch);
59 -- Character literal case. If the initial character is a quote, then
60 -- we read as far as we can without backup (see ACVC test CE3905L)
63 Store_Char (File, ch, Buf, Buflen);
67 if ch in 16#20# .. 16#7E# or else ch >= 16#80# then
68 Store_Char (File, ch, Buf, Buflen);
72 if ch = Character'Pos (''') then
73 Store_Char (File, ch, Buf, Buflen);
82 -- Similarly for identifiers, read as far as we can, in particular,
83 -- do read a trailing underscore (again see ACVC test CE3905L to
84 -- understand why we do this, although it seems somewhat peculiar).
87 -- Identifier must start with a letter
89 if not Is_Letter (C) then
94 -- If we do have a letter, loop through the characters quitting on
95 -- the first non-identifier character (note that this includes the
96 -- cases of hitting a line mark or page mark).
99 C := Character'Val (ch);
100 Store_Char (File, Character'Pos (To_Upper (C)), Buf, Buflen);
103 exit when ch = EOF_Char;
104 C := Character'Val (ch);
106 exit when not Is_Letter (C)
107 and then not Is_Digit (C)
111 and then Buf (Buflen) = '_';
128 Actual_Width : constant Count := Count'Max (Count (Width), Item'Length);
131 if Set = Lower_Case and then Item (Item'First) /= ''' then
133 Iteml : String (Item'First .. Item'Last);
136 for J in Item'Range loop
137 Iteml (J) := To_Lower (Item (J));
140 Put_Item (File, Iteml);
144 Put_Item (File, Item);
147 for J in 1 .. Actual_Width - Item'Length loop
164 if Item'Length > To'Length then
169 for J in Item'Range loop
170 if Set = Lower_Case and then Item (Item'First) /= ''' then
171 To (Ptr) := To_Lower (Item (J));
173 To (Ptr) := Item (J);
179 while Ptr <= To'Last loop
190 procedure Scan_Enum_Lit
197 -- Processing for Scan_Enum_Lit
200 String_Skip (From, Start);
202 -- Character literal case. If the initial character is a quote, then
203 -- we read as far as we can without backup (see ACVC test CE3905L
204 -- which is for the analogous case for reading from a file).
206 if From (Start) = ''' then
209 if Stop = From'Last then
215 if From (Stop) in ' ' .. '~'
216 or else From (Stop) >= Character'Val (16#80#)
218 if Stop = From'Last then
223 if From (Stop) = ''' then
231 -- Similarly for identifiers, read as far as we can, in particular,
232 -- do read a trailing underscore (again see ACVC test CE3905L to
233 -- understand why we do this, although it seems somewhat peculiar).
236 -- Identifier must start with a letter
238 if not Is_Letter (From (Start)) then
242 -- If we do have a letter, loop through the characters quitting on
243 -- the first non-identifier character (note that this includes the
244 -- cases of hitting a line mark or page mark).
247 while Stop < From'Last loop
248 C := From (Stop + 1);
250 exit when not Is_Letter (C)
251 and then not Is_Digit (C)
255 and then From (Stop) = '_';
262 end Ada.Text_IO.Enumeration_Aux;