adding experimental changes
This commit is contained in:
@ -1,38 +1,105 @@
|
||||
generic
|
||||
type Item_Type is (<>); -- any discrete type
|
||||
-- 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
|
||||
-- <ctype.h>-like character classification package
|
||||
-- <ctype.h>-like character classification plus other features.
|
||||
-- unicode-based. no system locale honored.
|
||||
|
||||
subtype Item_Code is H3.Natural;
|
||||
subtype Rune is Rune_Type;
|
||||
type Code is range -1 .. 16#7FFF_FFFF#;
|
||||
|
||||
Colon: constant Item_Code := System_Character'Pos(':');
|
||||
Semicolon: constant Item_Code := System_Character'Pos(';');
|
||||
Tilde: constant Item_Code := System_Character'Pos('~');
|
||||
Underline: constant Item_Code := System_Character'Pos('_');
|
||||
Equal: constant Item_Code := System_Character'Pos('=');
|
||||
L_Arrow: constant Item_Code := System_Character'Pos('<');
|
||||
R_Arrow: constant Item_Code := System_Character'Pos('>');
|
||||
-- virtual code to indicate end of input
|
||||
EOF: constant Code := Code'First;
|
||||
|
||||
type Item_Class is (ALPHA, ALNUM, BLANK, CNTRL, DIGIT, GRAPH, LOWER, PRINT, PUNCT, SPACE, UPPER, XDIGIT);
|
||||
function Is_Class (V: in Item_Type; Class: in Item_Class) return Boolean;
|
||||
C_Colon: constant Code := System_Rune'Pos(':');
|
||||
C_Semicolon: constant Code := System_Rune'Pos(';');
|
||||
C_Tilde: constant Code := System_Rune'Pos('~');
|
||||
C_Underline: constant Code := System_Rune'Pos('_');
|
||||
C_Equal: constant Code := System_Rune'Pos('=');
|
||||
C_Left_Arrow: constant Code := System_Rune'Pos('<');
|
||||
C_Right_Arrow: constant Code := System_Rune'Pos('>');
|
||||
|
||||
function Is_Alpha (V: in Item_Type) return Boolean;
|
||||
function Is_Alnum (V: in Item_Type) return Boolean;
|
||||
function Is_Blank (V: in Item_Type) return Boolean;
|
||||
function Is_Cntrl (V: in Item_Type) return Boolean;
|
||||
function Is_Digit (V: in Item_Type) return Boolean;
|
||||
function Is_Graph (V: in Item_Type) return Boolean;
|
||||
function Is_Print (V: in Item_Type) return Boolean;
|
||||
function Is_Punct (V: in Item_Type) return Boolean;
|
||||
function Is_Space (V: in Item_Type) return Boolean;
|
||||
function Is_Xdigit (V: in Item_Type) return Boolean;
|
||||
C_A: constant Code := System_Rune'Pos('A');
|
||||
C_B: constant Code := System_Rune'Pos('B');
|
||||
C_C: constant Code := System_Rune'Pos('C');
|
||||
C_D: constant Code := System_Rune'Pos('D');
|
||||
C_E: constant Code := System_Rune'Pos('E');
|
||||
|
||||
function Is_Lower (V: in Item_Type) return Boolean;
|
||||
function Is_Upper (V: in Item_Type) return Boolean;
|
||||
Colon: constant Rune := Rune'Val(C_Colon);
|
||||
Semicolon: constant Rune := Rune'Val(C_Semicolon);
|
||||
Tilde: constant Rune := Rune'Val(C_Tilde);
|
||||
Underline: constant Rune := Rune'Val(C_Underline);
|
||||
Equal: constant Rune := Rune'Val(C_Equal);
|
||||
Left_Arrow: constant Rune := Rune'Val(C_Left_Arrow);
|
||||
Right_Arrow: constant Rune := Rune'Val(C_Right_Arrow);
|
||||
|
||||
function To_Lower (V: in Item_Type) return Item_Type;
|
||||
function To_Upper (V: in Item_Type) return Item_Type;
|
||||
UC_A: constant Rune := Rune'Val(C_A);
|
||||
UC_B: constant Rune := Rune'Val(C_B);
|
||||
UC_C: constant Rune := Rune'Val(C_C);
|
||||
UC_D: constant Rune := Rune'Val(C_D);
|
||||
UC_E: constant Rune := Rune'Val(C_E);
|
||||
UC_O: constant Rune := Rune'Val(System_Rune'Pos('O'));
|
||||
UC_F: constant Rune := Rune'Val(System_Rune'Pos('F'));
|
||||
|
||||
type Item_Class is (
|
||||
ALPHA,
|
||||
ALNUM,
|
||||
BLANK,
|
||||
CNTRL,
|
||||
DIGIT,
|
||||
GRAPH,
|
||||
LOWER,
|
||||
PRINT,
|
||||
PUNCT,
|
||||
SPACE,
|
||||
UPPER,
|
||||
XDIGIT
|
||||
);
|
||||
|
||||
function Is_Alpha (V: in Rune) return Boolean;
|
||||
function Is_Alnum (V: in Rune) return Boolean;
|
||||
function Is_Blank (V: in Rune) return Boolean;
|
||||
function Is_Cntrl (V: in Rune) return Boolean;
|
||||
function Is_Digit (V: in Rune) return Boolean;
|
||||
function Is_Graph (V: in Rune) return Boolean;
|
||||
function Is_Print (V: in Rune) return Boolean;
|
||||
function Is_Punct (V: in Rune) return Boolean;
|
||||
function Is_Space (V: in Rune) return Boolean;
|
||||
function Is_Xdigit (V: in Rune) return Boolean;
|
||||
function Is_Lower (V: in Rune) return Boolean;
|
||||
function Is_Upper (V: in Rune) return Boolean;
|
||||
|
||||
function To_Lower (V: in Rune) return Rune;
|
||||
function To_Upper (V: in Rune) return Rune;
|
||||
|
||||
function Is_Alpha (C: in Code) return Boolean;
|
||||
function Is_Alnum (C: in Code) return Boolean;
|
||||
function Is_Blank (C: in Code) return Boolean;
|
||||
function Is_Cntrl (C: in Code) return Boolean;
|
||||
function Is_Digit (C: in Code) return Boolean;
|
||||
function Is_Graph (C: in Code) return Boolean;
|
||||
function Is_Print (C: in Code) return Boolean;
|
||||
function Is_Punct (C: in Code) return Boolean;
|
||||
function Is_Space (C: in Code) return Boolean;
|
||||
function Is_Xdigit (C: in Code) return Boolean;
|
||||
function Is_Lower (C: in Code) return Boolean;
|
||||
function Is_Upper (C: in Code) return Boolean;
|
||||
|
||||
function Is_Class (V: in Rune; Class: in Item_Class) return Boolean;
|
||||
function Is_Class (C: in Code; Class: in Item_Class) return Boolean;
|
||||
|
||||
function Is_Eof (C: in Code) return Boolean;
|
||||
pragma Inline (Is_Eof);
|
||||
|
||||
function Is_Code (V: in Rune; C: in Code) return Boolean;
|
||||
pragma Inline (Is_Code);
|
||||
function Is_Rune (C: in Code; V: in Rune) return Boolean;
|
||||
pragma Inline (Is_Rune);
|
||||
|
||||
function To_Rune (C: in Code) return Rune;
|
||||
pragma Inline (To_Rune);
|
||||
function To_Code (V: in Rune) return Code;
|
||||
pragma Inline (To_Code);
|
||||
|
||||
function Is_Code (V: in Item_Type; Code: in Item_Code) return Boolean;
|
||||
end H3.CC;
|
Reference in New Issue
Block a user