CharOps.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Doug Wyatt, October 17, 1991 5:07 pm PDT
DIRECTORY
Char USING [XCHAR, CharSet, CharCode, Code, Set, Widen];
CharOps:
CEDAR
DEFINITIONS
IMPORTS Char ~
BEGIN
CharProperty: TYPE ~ MACHINE DEPENDENT {other, blank, alphaNumeric, punctuation, (255)};
CharPropertyTable: TYPE = PACKED ARRAY CHAR OF CharProperty;
charPropertyTable: REF READONLY CharPropertyTable;
Prop:
PROC [c:
CHAR]
RETURNS [CharProperty]
= INLINE { RETURN [charPropertyTable[c]] };
Blank:
PROC [c:
CHAR]
RETURNS [
BOOL]
= INLINE { RETURN [charPropertyTable[c] = blank] };
AlphaNumeric:
PROC [c:
CHAR]
RETURNS [
BOOL]
= INLINE { RETURN [charPropertyTable[c] = alphaNumeric] };
Punctuation:
PROC [c:
CHAR]
RETURNS [
BOOL]
= INLINE { RETURN [charPropertyTable[c] = punctuation] };
Upper:
PROC [c:
CHAR]
RETURNS [
CHAR]
= INLINE { RETURN [IF c IN ['a..'z] THEN (c-'a)+'A ELSE c] };
Lower:
PROC [c:
CHAR]
RETURNS [
CHAR]
= INLINE { RETURN [IF c IN ['A..'Z] THEN (c-'A)+'a ELSE c] };
XCHAR:
TYPE ~ Char.
XCHAR;
Char0:
PROC [c:
XCHAR]
RETURNS [
CHAR]
= INLINE { RETURN [VAL[Char.Code[c]]] };
XProp:
PROC [c:
XCHAR]
RETURNS [CharProperty]
= INLINE { RETURN [IF Char.Set[c]=0 THEN Prop[Char0[c]] ELSE other] };
XBlank:
PROC [c:
XCHAR]
RETURNS [
BOOL]
= INLINE { RETURN [Char.Set[c]=0 AND Blank[Char0[c]]] };
XAlphaNumeric:
PROC [c:
XCHAR]
RETURNS [
BOOL]
= INLINE { RETURN [Char.Set[c]=0 AND AlphaNumeric[Char0[c]]] };
XPunctuation:
PROC [c:
XCHAR]
RETURNS [
BOOL]
= INLINE { RETURN [Char.Set[c]=0 AND Punctuation[Char0[c]]] };
XUpper:
PROC [c:
XCHAR]
RETURNS [
XCHAR]
= INLINE { RETURN [IF Char.Set[c]=0 THEN Char.Widen[Upper[Char0[c]]] ELSE c] };
XLower:
PROC [c:
XCHAR]
RETURNS [
XCHAR]
= INLINE { RETURN [IF Char.Set[c]=0 THEN Char.Widen[Lower[Char0[c]]] ELSE c] };
END.