some code clean-up
This commit is contained in:
parent
ef734a5bc1
commit
2625942e08
@ -84,9 +84,9 @@ package body H3.CC is
|
|||||||
return Item_Type'Val(UC.UTF_32_To_Upper_Case(Item_Type'Pos(V)));
|
return Item_Type'Val(UC.UTF_32_To_Upper_Case(Item_Type'Pos(V)));
|
||||||
end To_Upper;
|
end To_Upper;
|
||||||
|
|
||||||
function Is_Class (V: in Item_Type; Cls: in Class) return Boolean is
|
function Is_Class (V: in Item_Type; Class: in Item_Class) return Boolean is
|
||||||
begin
|
begin
|
||||||
case Cls is
|
case Class is
|
||||||
when ALPHA => return Is_Alpha(V);
|
when ALPHA => return Is_Alpha(V);
|
||||||
when ALNUM => return Is_Alnum(V);
|
when ALNUM => return Is_Alnum(V);
|
||||||
when BLANK => return Is_Blank(V);
|
when BLANK => return Is_Blank(V);
|
||||||
|
@ -7,15 +7,15 @@ package H3.CC is
|
|||||||
subtype Item_Code is H3.Natural;
|
subtype Item_Code is H3.Natural;
|
||||||
|
|
||||||
Colon: constant Item_Code := System_Character'Pos(':');
|
Colon: constant Item_Code := System_Character'Pos(':');
|
||||||
SemicoloN: constant Item_Code := System_Character'Pos(';');
|
Semicolon: constant Item_Code := System_Character'Pos(';');
|
||||||
Tilde: constant Item_Code := System_Character'Pos('~');
|
Tilde: constant Item_Code := System_Character'Pos('~');
|
||||||
Underline: constant Item_Code := System_Character'Pos('_');
|
Underline: constant Item_Code := System_Character'Pos('_');
|
||||||
Equal: constant Item_Code := System_Character'Pos('=');
|
Equal: constant Item_Code := System_Character'Pos('=');
|
||||||
L_Arrow: constant Item_Code := System_Character'Pos('<');
|
L_Arrow: constant Item_Code := System_Character'Pos('<');
|
||||||
R_Arrow: constant Item_Code := System_Character'Pos('>');
|
R_Arrow: constant Item_Code := System_Character'Pos('>');
|
||||||
|
|
||||||
type Class is (ALPHA, ALNUM, BLANK, CNTRL, DIGIT, GRAPH, LOWER, PRINT, PUNCT, SPACE, UPPER, XDIGIT);
|
type Item_Class is (ALPHA, ALNUM, BLANK, CNTRL, DIGIT, GRAPH, LOWER, PRINT, PUNCT, SPACE, UPPER, XDIGIT);
|
||||||
function Is_Class (V: in Item_Type; Cls: in Class) return Boolean;
|
function Is_Class (V: in Item_Type; Class: in Item_Class) return Boolean;
|
||||||
|
|
||||||
function Is_Alpha (V: in Item_Type) return Boolean;
|
function Is_Alpha (V: in Item_Type) return Boolean;
|
||||||
function Is_Alnum (V: in Item_Type) return Boolean;
|
function Is_Alnum (V: in Item_Type) return Boolean;
|
||||||
|
@ -29,9 +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; Cls: CC.Class) return Standard.Boolean is
|
function is_class (V: Standard.Wide_Character; Class: CC.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;
|
||||||
@ -60,7 +58,7 @@ procedure hello2 is
|
|||||||
use type C.int;
|
use type C.int;
|
||||||
X: C.int := Standard.Wide_Character'Pos(V);
|
X: C.int := Standard.Wide_Character'Pos(V);
|
||||||
begin
|
begin
|
||||||
case Cls is
|
case Class is
|
||||||
when CC.ALPHA => return IswAlpha(X) /= 0;
|
when CC.ALPHA => return IswAlpha(X) /= 0;
|
||||||
when CC.ALNUM => return IswAlnum(X) /= 0;
|
when CC.ALNUM => return IswAlnum(X) /= 0;
|
||||||
when CC.BLANK => return IswBlank(X) /= 0;
|
when CC.BLANK => return IswBlank(X) /= 0;
|
||||||
@ -122,7 +120,7 @@ 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.Class'Range loop
|
for j in CC.Item_Class'Range loop
|
||||||
Ada.Text_IO.Put (" " & J'Img & ":" & CC.Is_Class(ch, j)'Img);
|
Ada.Text_IO.Put (" " & J'Img & ":" & CC.Is_Class(ch, j)'Img);
|
||||||
if CC.Is_Class(ch, j) /= Is_Class(ch, j) then
|
if CC.Is_Class(ch, j) /= Is_Class(ch, j) then
|
||||||
Ada.Text_IO.Put ("[X]");
|
Ada.Text_IO.Put ("[X]");
|
||||||
|
Loading…
Reference in New Issue
Block a user