annotate gcc/ada/widechar.ads @ 120:f93fa5091070

fix conv1.c
author mir3636
date Thu, 08 Mar 2018 14:53:42 +0900
parents 04ced10e8804
children 84e7813d76e9
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 COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- W I D E C H A R --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
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 -- Subprograms for manipulation of wide character sequences. Note that in
kono
parents:
diff changeset
33 -- this package, wide character and wide wide character are not distinguished
kono
parents:
diff changeset
34 -- since this package is basically concerned with syntactic notions, and it
kono
parents:
diff changeset
35 -- deals with Char_Code values, rather than values of actual Ada types.
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 with Types; use Types;
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 package Widechar is
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 Wide_Char_Byte_Count : Nat := 0;
kono
parents:
diff changeset
42 -- This value is incremented whenever Scan_Wide or Skip_Wide is called.
kono
parents:
diff changeset
43 -- The amount added is the length of the wide character sequence minus
kono
parents:
diff changeset
44 -- one. This means that the count that accumulates here represents the
kono
parents:
diff changeset
45 -- difference between the length in characters and the length in bytes.
kono
parents:
diff changeset
46 -- This is used for checking the line length in characters.
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 function Length_Wide return Nat;
kono
parents:
diff changeset
49 -- Returns the maximum length in characters for the escape sequence that
kono
parents:
diff changeset
50 -- is used to encode wide character literals outside the ASCII range. Used
kono
parents:
diff changeset
51 -- only in the implementation of the attribute Width for Wide_Character
kono
parents:
diff changeset
52 -- and Wide_Wide_Character.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure Scan_Wide
kono
parents:
diff changeset
55 (S : Source_Buffer_Ptr;
kono
parents:
diff changeset
56 P : in out Source_Ptr;
kono
parents:
diff changeset
57 C : out Char_Code;
kono
parents:
diff changeset
58 Err : out Boolean);
kono
parents:
diff changeset
59 -- On entry S (P) points to the first character in the source text for
kono
parents:
diff changeset
60 -- a wide character (i.e. to an ESC character, a left bracket, or an
kono
parents:
diff changeset
61 -- upper half character, depending on the representation method). A
kono
parents:
diff changeset
62 -- single wide character is scanned. If no error is found, the value
kono
parents:
diff changeset
63 -- stored in C is the code for this wide character, P is updated past
kono
parents:
diff changeset
64 -- the sequence and Err is set to False. If an error is found, then
kono
parents:
diff changeset
65 -- P points to the improper character, C is undefined, and Err is
kono
parents:
diff changeset
66 -- set to True.
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 procedure Set_Wide
kono
parents:
diff changeset
69 (C : Char_Code;
kono
parents:
diff changeset
70 S : in out String;
kono
parents:
diff changeset
71 P : in out Natural);
kono
parents:
diff changeset
72 -- The escape sequence (including any leading ESC character) for the
kono
parents:
diff changeset
73 -- given character code is stored starting at S (P + 1), and on return
kono
parents:
diff changeset
74 -- P points to the last stored character (i.e. P is the count of stored
kono
parents:
diff changeset
75 -- characters on entry and exit, and the escape sequence is appended to
kono
parents:
diff changeset
76 -- the end of the stored string). The character code C represents a code
kono
parents:
diff changeset
77 -- originally constructed by Scan_Wide, so it is known to be in a range
kono
parents:
diff changeset
78 -- that is appropriate for the encoding method in use.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Skip_Wide (S : String; P : in out Natural);
kono
parents:
diff changeset
81 -- On entry, S (P) points to an ESC character for a wide character escape
kono
parents:
diff changeset
82 -- sequence or to an upper half character if the encoding method uses the
kono
parents:
diff changeset
83 -- upper bit, or to a left bracket if the brackets encoding method is in
kono
parents:
diff changeset
84 -- use. On exit, P is bumped past the wide character sequence. No error
kono
parents:
diff changeset
85 -- checking is done, since this is only used on escape sequences generated
kono
parents:
diff changeset
86 -- by Set_Wide, which are known to be correct.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 procedure Skip_Wide (S : Source_Buffer_Ptr; P : in out Source_Ptr);
kono
parents:
diff changeset
89 -- Similar to the above procedure, but operates on a source buffer
kono
parents:
diff changeset
90 -- instead of a string, with P being a Source_Ptr referencing the
kono
parents:
diff changeset
91 -- contents of the source buffer.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 function Is_Start_Of_Wide_Char
kono
parents:
diff changeset
94 (S : Source_Buffer_Ptr;
kono
parents:
diff changeset
95 P : Source_Ptr) return Boolean;
kono
parents:
diff changeset
96 -- Determines if S (P) is the start of a wide character sequence
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 private
kono
parents:
diff changeset
99 pragma Inline (Is_Start_Of_Wide_Char);
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 end Widechar;