renamed H3.CC to H3.Runes

This commit is contained in:
hyung-hwan 2021-10-30 05:32:16 +00:00
parent eadeb5af07
commit 0a8c9c3a84
8 changed files with 32 additions and 29 deletions

View File

@ -6,6 +6,7 @@ generic
G_Terminator_Length: System_Zero_Or_One;
G_Terminator_Value: Item_Type;
package H3.Arrays is
--pragma Preelaborate (Arrays);
subtype Item is Item_Type;

View File

@ -1,10 +1,10 @@
with H3.CC;
with H3.Runes;
with H3.Strings;
generic
type Rune_Type is (<>);
package H3.Compilers is
package R is new H3.CC(Rune_Type);
package R is new H3.Runes(Rune_Type);
package S is new H3.Strings(Rune_Type);
Syntax_Error: exception;

View File

@ -1,6 +1,6 @@
with System.UTF_32; -- TOOD: remove dependency on this package. create a seperate unicode package.
package body H3.CC is
package body H3.Runes is
package UC renames System.UTF_32;
use type System.UTF_32.Category;
@ -195,4 +195,4 @@ package body H3.CC is
return Rune'Pos(V);
end To_Code;
end H3.CC;
end H3.Runes;

View File

@ -2,7 +2,7 @@ generic
-- any discrete type accepted.
-- can't ada limit type to one of Character, Wide_Character, Wide_Wide_Character?
type Rune_Type is (<>);
package H3.CC is
package H3.Runes is
-- <ctype.h>-like character classification plus other features.
-- unicode-based. no system locale honored.
@ -102,4 +102,4 @@ package H3.CC is
function To_Code (V: in Rune) return Code;
pragma Inline (To_Code);
end H3.CC;
end H3.Runes;

View File

@ -3,6 +3,7 @@ with System.Storage_Pools;
package H3 is
--pragma Preelaborate (H3);
subtype Boolean is Standard.Boolean;
subtype Natural is Standard.Natural;

View File

@ -176,7 +176,7 @@ begin
declare
-- unsafe way to access the internal buffer.
--arr: constant S.P.Item_Array := S.To_Item_Array(Str);
arr: constant S.Character_Array := S.To_Item_Array(Str);
arr: constant S.Rune_Array := S.To_Item_Array(Str);
begin
Ada.Wide_Text_IO.Put ("STR[1] => [");
for i in arr'Range loop
@ -357,8 +357,8 @@ begin
declare
--arr: constant S.P.Thin_Item_Array_Pointer := S.Get_Slot_Pointer(Str);
--arr2: constant S.P.Thin_Item_Array_Pointer := S.Get_Slot_Pointer(Str2);
arr: constant S.Thin_Character_Array_Pointer := S.Get_Slot_Pointer(Str);
arr2: constant S.Thin_Character_Array_Pointer := S.Get_Slot_Pointer(Str2);
arr: constant S.Thin_Rune_Array_Pointer := S.Get_Slot_Pointer(Str);
arr2: constant S.Thin_Rune_Array_Pointer := S.Get_Slot_Pointer(Str2);
use type H3.System_Word;
begin
print_string_info (Str, "Str");

View File

@ -1,6 +1,6 @@
with H3.Arrays;
with H3.Strings;
with H3.CC;
with H3.Runes;
with Ada.Text_IO;
with Ada.Wide_Text_IO;
with Ada.Assertions;
@ -13,7 +13,7 @@ use type H3.System_Size;
procedure hello2 is
package A is new H3.Arrays(Standard.Wide_Character, 1, Wide_Character'First);
package S is new H3.Strings(Standard.Wide_Character);
package CC is new H3.CC(Standard.Wide_Character);
package R is new H3.Runes(Standard.Wide_Character);
package C renames Interfaces.C;
--package S_I is new H3.Arrays(Integer, 1, 16#FF#);
@ -29,7 +29,7 @@ procedure hello2 is
procedure setlocale(a: C.int; b: System.Address);
pragma Import (C, setlocale, "setlocale");
function is_class (V: Standard.Wide_Character; Class: CC.Item_Class) return Standard.Boolean is
function is_class (V: Standard.Wide_Character; Class: R.Item_Class) return Standard.Boolean is
function iswalpha(a: C.int) return C.int;
pragma Import (C, iswalpha, "iswalpha");
function iswalnum(a: C.int) return C.int;
@ -59,18 +59,18 @@ procedure hello2 is
X: C.int := Standard.Wide_Character'Pos(V);
begin
case Class is
when CC.ALPHA => return IswAlpha(X) /= 0;
when CC.ALNUM => return IswAlnum(X) /= 0;
when CC.BLANK => return IswBlank(X) /= 0;
when CC.CNTRL => return IswCntrl(X) /= 0;
when CC.DIGIT => return IswDigit(X) /= 0;
when CC.GRAPH => return IswGraph(X) /= 0;
when CC.LOWER => return IswLower(X) /= 0;
when CC.PRINT => return IswPrint(X) /= 0;
when CC.PUNCT => return IswPunct(X) /= 0;
when CC.SPACE => return IswSpace(X) /= 0;
when CC.UPPER => return IswUpper(X) /= 0;
when CC.XDIGIT => return IswXdigit(X) /= 0;
when R.ALPHA => return IswAlpha(X) /= 0;
when R.ALNUM => return IswAlnum(X) /= 0;
when R.BLANK => return IswBlank(X) /= 0;
when R.CNTRL => return IswCntrl(X) /= 0;
when R.DIGIT => return IswDigit(X) /= 0;
when R.GRAPH => return IswGraph(X) /= 0;
when R.LOWER => return IswLower(X) /= 0;
when R.PRINT => return IswPrint(X) /= 0;
when R.PUNCT => return IswPunct(X) /= 0;
when R.SPACE => return IswSpace(X) /= 0;
when R.UPPER => return IswUpper(X) /= 0;
when R.XDIGIT => return IswXdigit(X) /= 0;
end case;
end is_class;
@ -120,9 +120,9 @@ begin
ch := Standard.Wide_Character'Val(i);
Ada.Text_IO.Put (I'img & "[" & ch'Img & "]");
for j in CC.Item_Class'Range loop
Ada.Text_IO.Put (" " & J'Img & ":" & CC.Is_Class(ch, j)'Img);
if CC.Is_Class(ch, j) /= Is_Class(ch, j) then
for j in R.Item_Class'Range loop
Ada.Text_IO.Put (" " & J'Img & ":" & R.Is_Class(ch, j)'Img);
if R.Is_Class(ch, j) /= Is_Class(ch, j) then
Ada.Text_IO.Put ("[X]");
--else
-- Ada.Text_IO.Put ("[O]");
@ -132,7 +132,7 @@ begin
Ada.Text_IO.Put_Line ("");
end loop;
Ada.Text_IO.Put_line (CC.Is_Alpha('σ')'Img);
Ada.Text_IO.Put_line (R.Is_Alpha('σ')'Img);
end;
end;

View File

@ -1,4 +1,5 @@
with H3.Compilers;
with ada.text_io;
procedure hello3 is
package C is new H3.Compilers(Standard.Wide_Character);