diff options
-rw-r--r-- | src/packrat-util.adb | 47 | ||||
-rw-r--r-- | test/ratnest-tests.adb | 4 |
2 files changed, 37 insertions, 14 deletions
diff --git a/src/packrat-util.adb b/src/packrat-util.adb index 6ee1d4a..dc9968b 100644 --- a/src/packrat-util.adb +++ b/src/packrat-util.adb @@ -1,8 +1,18 @@ +with + + Ada.Characters.Latin_1; + + package body Packrat.Util is + package Latin renames Ada.Characters.Latin_1; + + + + function In_Set (Element : in Character) return Boolean is @@ -26,7 +36,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return (Char >= '0' and Char <= '9'); end Is_Digit; @@ -34,7 +44,10 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return + (Char >= '0' and Char <= '9') or + (Char >= 'A' and Char <= 'F') or + (Char >= 'a' and Char <= 'f'); end Is_Hex; @@ -42,7 +55,9 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return + (Char >= 'A' and Char <= 'Z') or + (Char >= 'a' and Char <= 'z'); end Is_Letter; @@ -50,7 +65,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return Is_Digit (Char) or Is_Letter (Char); end Is_Alphanumeric; @@ -58,7 +73,11 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return + (Char >= '!' and Char <= '/') or + (Char >= ':' and Char <= '@') or + (Char >= '[' and Char <= '`') or + (Char >= '{' and Char <= '~'); end Is_Punctuation; @@ -66,7 +85,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return Char <= Character'Val (127); end Is_ASCII; @@ -74,7 +93,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return Char >= Character'Val (128); end Is_Extended_ASCII; @@ -82,7 +101,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return Char = ' '; end Is_Space; @@ -90,7 +109,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return (Char = ' ' or Char = Latin.HT); end Is_Linespace; @@ -98,7 +117,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return (Char = Latin.LF or Char = Latin.CR); end Is_End_Of_Line; @@ -106,7 +125,11 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return + Char = Latin.HT or + Char = Latin.LF or + Char = Latin.CR or + Char = ' '; end Is_Whitespace; @@ -114,7 +137,7 @@ package body Packrat.Util is (Char : in Character) return Boolean is begin - return False; + return not Is_Whitespace (Char); end Not_Whitespace; diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb index dd2228f..2479998 100644 --- a/test/ratnest-tests.adb +++ b/test/ratnest-tests.adb @@ -226,12 +226,12 @@ package body Ratnest.Tests is return Test_Result is begin for I in Integer range Character'Pos (Character'First) .. 127 loop - if PU.Is_ASCII (Character'Val (I)) then + if PU.Is_Extended_ASCII (Character'Val (I)) then return Failure; end if; end loop; for I in Integer range 128 .. Character'Pos (Character'Last) loop - if not PU.Is_ASCII (Character'Val (I)) then + if not PU.Is_Extended_ASCII (Character'Val (I)) then return Failure; end if; end loop; |