1(* $Id: CharClass.Mod,v 1.6 1999/10/03 11:43:57 ooc-devel Exp $ *) 2MODULE oocCharClass; 3(* Classification of values of the type CHAR. 4 Copyright (C) 1997-1998 Michael van Acken 5 6 This module is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public License 8 as published by the Free Software Foundation; either version 2 of 9 the License, or (at your option) any later version. 10 11 This module is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with OOC. If not, write to the Free Software Foundation, 18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19*) 20 21(* 22Notes: 23- This module boldly assumes ASCII character encoding. ;-) 24- The value `eol' and the procedure `IsEOL' are not part of the Modula-2 25 DIS. OOC defines them to fixed values for all its implementations, 26 independent of the target system. The string `systemEol' holds the target 27 system's end of line marker, which can be longer than one byte (but cannot 28 contain 0X). 29*) 30 31IMPORT 32 Ascii := oocAscii; 33 34CONST 35 eol* = Ascii.lf; 36 (* the implementation-defined character used to represent end of line 37 internally for OOC *) 38 39VAR 40 systemEol-: ARRAY 3 OF CHAR; 41 (* End of line marker used by the target system for text files. The string 42 defined here can contain more than one character. For one character eol 43 markers, `systemEol' must not necessarily equal `eol'. Note that the 44 string cannot contain the termination character 0X. *) 45 46 47PROCEDURE IsNumeric* (ch: CHAR): BOOLEAN; 48(* Returns TRUE if and only if ch is classified as a numeric character *) 49 BEGIN 50 RETURN ("0" <= ch) & (ch <= "9") 51 END IsNumeric; 52 53PROCEDURE IsLetter* (ch: CHAR): BOOLEAN; 54(* Returns TRUE if and only if ch is classified as a letter *) 55 BEGIN 56 RETURN ("a" <= ch) & (ch <= "z") OR ("A" <= ch) & (ch <= "Z") 57 END IsLetter; 58 59PROCEDURE IsUpper* (ch: CHAR): BOOLEAN; 60(* Returns TRUE if and only if ch is classified as an upper case letter *) 61 BEGIN 62 RETURN ("A" <= ch) & (ch <= "Z") 63 END IsUpper; 64 65PROCEDURE IsLower* (ch: CHAR): BOOLEAN; 66(* Returns TRUE if and only if ch is classified as a lower case letter *) 67 BEGIN 68 RETURN ("a" <= ch) & (ch <= "z") 69 END IsLower; 70 71PROCEDURE IsControl* (ch: CHAR): BOOLEAN; 72(* Returns TRUE if and only if ch represents a control function *) 73 BEGIN 74 RETURN (ch < Ascii.sp) 75 END IsControl; 76 77PROCEDURE IsWhiteSpace* (ch: CHAR): BOOLEAN; 78(* Returns TRUE if and only if ch represents a space character or a format 79 effector *) 80 BEGIN 81 RETURN (ch = Ascii.sp) OR (ch = Ascii.ff) OR (ch = Ascii.lf) OR 82 (ch = Ascii.cr) OR (ch = Ascii.ht) OR (ch = Ascii.vt) 83 END IsWhiteSpace; 84 85 86PROCEDURE IsEol* (ch: CHAR): BOOLEAN; 87(* Returns TRUE if and only if ch is the implementation-defined character used 88 to represent end of line internally for OOC. *) 89 BEGIN 90 RETURN (ch = eol) 91 END IsEol; 92 93BEGIN 94 systemEol[0] := Ascii.lf; systemEol[1] := 0X 95END oocCharClass. 96