| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- C S E T S -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 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 3, 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 COPYING3. If not, go to -- |
| 19 |
-- http://www.gnu.org/licenses for a complete copy of the license. -- |
| 20 |
-- -- |
| 21 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 22 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 23 |
-- -- |
| 24 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
package Csets is |
| 27 |
pragma Elaborate_Body; |
| 28 |
|
| 29 |
-- This package contains character tables for the various character |
| 30 |
-- sets that are supported for source representation. Character and |
| 31 |
-- string literals are not affected, only identifiers. For each set, |
| 32 |
-- the table in this package gives the mapping of letters to their |
| 33 |
-- upper case equivalent. Each table thus provides the information |
| 34 |
-- for building the table used to fold lower case to upper case, and |
| 35 |
-- also the table of flags showing which characters are allowed in |
| 36 |
-- identifiers. |
| 37 |
|
| 38 |
type Translate_Table is array (Character) of Character; |
| 39 |
-- Type used to describe translate tables |
| 40 |
|
| 41 |
type Char_Array_Flags is array (Character) of Boolean; |
| 42 |
-- Type used for character attribute arrays. Note that we deliberately |
| 43 |
-- do NOT pack this table, since we don't want the extra overhead of |
| 44 |
-- accessing a packed bit string. |
| 45 |
|
| 46 |
---------------------------------------------- |
| 47 |
-- Character Tables For Current Compilation -- |
| 48 |
---------------------------------------------- |
| 49 |
|
| 50 |
procedure Initialize; |
| 51 |
-- Routine to initialize following character tables, whose content depends |
| 52 |
-- on the character code being used to represent the source program. In |
| 53 |
-- particular, the use of the upper half of the 8-bit code set varies. |
| 54 |
-- The character set in use is specified by the value stored in |
| 55 |
-- Opt.Identifier_Character_Set, which has the following settings: |
| 56 |
|
| 57 |
-- '1' Latin-1 (ISO-8859-1) |
| 58 |
-- '2' Latin-2 (ISO-8859-2) |
| 59 |
-- '3' Latin-3 (ISO-8859-3) |
| 60 |
-- '4' Latin-4 (ISO-8859-4) |
| 61 |
-- '5' Cyrillic (ISO-8859-5) |
| 62 |
-- 'p' IBM PC (code page 437) |
| 63 |
-- '8' IBM PC (code page 850) |
| 64 |
-- '9' Latin-9 (ISO-8859-15) |
| 65 |
-- 'f' Full upper set (all distinct) |
| 66 |
-- 'n' No upper characters (Ada/83 rules) |
| 67 |
-- 'w' Latin-1 plus wide characters also allowed |
| 68 |
|
| 69 |
function Is_Upper_Case_Letter (C : Character) return Boolean; |
| 70 |
pragma Inline (Is_Upper_Case_Letter); |
| 71 |
-- Determine if character is upper case letter |
| 72 |
|
| 73 |
function Is_Lower_Case_Letter (C : Character) return Boolean; |
| 74 |
pragma Inline (Is_Lower_Case_Letter); |
| 75 |
-- Determine if character is lower case letter |
| 76 |
|
| 77 |
Fold_Upper : Translate_Table; |
| 78 |
-- Table to fold lower case identifier letters to upper case |
| 79 |
|
| 80 |
Fold_Lower : Translate_Table; |
| 81 |
-- Table to fold upper case identifier letters to lower case |
| 82 |
|
| 83 |
function Identifier_Char (Item : Character) return Boolean; |
| 84 |
-- Return True for all characters that can legally appear in identifiers, |
| 85 |
-- including digits, the underline character, all letters including upper |
| 86 |
-- and lower case and extended letters (as controlled by the setting of |
| 87 |
-- Opt.Identifier_Character_Set), left bracket for brackets notation wide |
| 88 |
-- characters and also ESC if wide characters are permitted in identifiers |
| 89 |
-- using escape sequences starting with ESC. |
| 90 |
|
| 91 |
end Csets; |