From 0a8c9c3a84923f7daf26641f4e4611e40672dc5a Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 30 Oct 2021 05:32:16 +0000 Subject: [PATCH] renamed H3.CC to H3.Runes --- lib2/h3-arrays.ads | 1 + lib2/h3-compilers.ads | 6 ++--- lib2/{h3-cc.adb => h3-runes.adb} | 4 ++-- lib2/{h3-cc.ads => h3-runes.ads} | 4 ++-- lib2/h3.ads | 1 + lib2/hello.adb | 6 ++--- lib2/hello2.adb | 38 ++++++++++++++++---------------- lib2/hello3.adb | 1 + 8 files changed, 32 insertions(+), 29 deletions(-) rename lib2/{h3-cc.adb => h3-runes.adb} (99%) rename lib2/{h3-cc.ads => h3-runes.ads} (99%) diff --git a/lib2/h3-arrays.ads b/lib2/h3-arrays.ads index 8c485b2..2fc2ba9 100644 --- a/lib2/h3-arrays.ads +++ b/lib2/h3-arrays.ads @@ -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; diff --git a/lib2/h3-compilers.ads b/lib2/h3-compilers.ads index b72f3b7..f349352 100644 --- a/lib2/h3-compilers.ads +++ b/lib2/h3-compilers.ads @@ -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; @@ -55,4 +55,4 @@ private Lx: Lexer; Tk: Token; end record; -end H3.Compilers; \ No newline at end of file +end H3.Compilers; diff --git a/lib2/h3-cc.adb b/lib2/h3-runes.adb similarity index 99% rename from lib2/h3-cc.adb rename to lib2/h3-runes.adb index ea13115..5c25ec1 100644 --- a/lib2/h3-cc.adb +++ b/lib2/h3-runes.adb @@ -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; \ No newline at end of file +end H3.Runes; diff --git a/lib2/h3-cc.ads b/lib2/h3-runes.ads similarity index 99% rename from lib2/h3-cc.ads rename to lib2/h3-runes.ads index 28a0157..7ee15ef 100644 --- a/lib2/h3-cc.ads +++ b/lib2/h3-runes.ads @@ -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 -- -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; \ No newline at end of file +end H3.Runes; diff --git a/lib2/h3.ads b/lib2/h3.ads index 486c783..edbb3a3 100644 --- a/lib2/h3.ads +++ b/lib2/h3.ads @@ -3,6 +3,7 @@ with System.Storage_Pools; package H3 is --pragma Preelaborate (H3); + subtype Boolean is Standard.Boolean; subtype Natural is Standard.Natural; diff --git a/lib2/hello.adb b/lib2/hello.adb index 5434d1d..82220fc 100644 --- a/lib2/hello.adb +++ b/lib2/hello.adb @@ -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"); diff --git a/lib2/hello2.adb b/lib2/hello2.adb index 8e04642..a5252a1 100644 --- a/lib2/hello2.adb +++ b/lib2/hello2.adb @@ -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; diff --git a/lib2/hello3.adb b/lib2/hello3.adb index 330c0ff..dcbc777 100644 --- a/lib2/hello3.adb +++ b/lib2/hello3.adb @@ -1,4 +1,5 @@ with H3.Compilers; +with ada.text_io; procedure hello3 is package C is new H3.Compilers(Standard.Wide_Character);