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_Length: System_Zero_Or_One;
G_Terminator_Value: Item_Type; G_Terminator_Value: Item_Type;
package H3.Arrays is package H3.Arrays is
--pragma Preelaborate (Arrays);
subtype Item is Item_Type; subtype Item is Item_Type;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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