abs_strings.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------


abstract class $STRINGS < $NIL, $HASH

abstract class $STRINGS < $NIL, $HASH is -- This abstraction is the 'root' of all string classes for file -- manipulation purposes. -- Version 1.2 Sep 2001. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 19 Jun 97 kh Original -- 28 Nov 00 kh Simplified inheritance -- 21 Sep 01 kh Added $NIL sub-typing array_ptr : REFERENCE ; -- This returns the array pointer for the contents for use in -- external input or output. head(cnt : CARD) : SAME ; -- This returns either cnt elements from the head of self or the -- contents of self if that is shorter. tail(cnt : CARD) : SAME ; -- This returns either cnt elements from the end of self or the contents -- of self if that is shorter. substring(beg,num : CARD) : SAME ; -- This returns the substring of num elements of self begining with the -- one whose index is beg. Self may only be void if both beg and num are zero. end ; -- $STRINGS

abstract class $STRING{ETP < $IS_EQ} < $STRINGS, $LISTS{ETP}

abstract class $STRING{ETP < $IS_EQ} < $STRINGS, $LISTS{ETP} is -- This abstract class characterises all forms of string whether binary, -- text or other. The implementations of this class shall provide immutable -- semantics! -- Version 1.1 Nov 2000. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 20 Apr 99 kh Modified for Version 8 of text classes -- 28 Nov 00 kh Simplified string inheritance end ; -- $STRING{ETP}

abstract class $SEARCH{ETP < $IS_EQ, STP} < $STRINGS

abstract class $SEARCH{ETP < $IS_EQ, STP} < $STRINGS is -- This abstract class characterises a searchable string of any kind. -- Version 1.1 Nov 2000. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 30 Nov 00 kh Original - simplifying string inheritance is_prefix(other : STP) : BOOL ; -- This predicate returns true if and only if other is identical to the -- bit-pattern starting at the beginning of self. search(elem : ETP) : CARD ; -- This routine returns the index in self at which elem is first found -- or if not present then CARD::nil. search(elem : ETP,start : CARD) : CARD ; -- This routine returms the index in self at which elem is first found -- at or after index start - or if not present then CARD::nil. search( str : STP) : CARD ; -- This routine returns the index of the leftmost substring of self -- which completely matches str. If there is no such position then -- CARD::nil is returned. search(str : STP,start : CARD) : CARD ; -- This routine returns the index of the first appearance of the entire -- string str in self starting from the index start. CARD::nil is -- returned if no such position is found. search_backwards(elem : ETP) : CARD ; -- This routine returns the index of the last occurrence of elem in -- self -- or CARD::nil if not found at all. search_backwards(elem : ETP,start : CARD) : CARD ; -- This routine returns the index in self at which the bit-pattern elem -- is first found starting to search backwards from index start. If not -- found then CARD::nil is returned. mismatch(other : STP) : CARD ; -- This routine returns the index of the first element of self which has -- a different element value from other or CARD::nil if self is a prefix -- of other. end ; -- $SEARCH{ETP,STP}

abstract class $STRING{ETP<$IS_EQ, FSTP<$FSTRING{ETP}, STP< $STRING{ETP}} < $STRING{ETP}, $SEARCH{ETP,STP}, $BINARY

abstract class $STRING{ETP<$IS_EQ, FSTP<$FSTRING{ETP}, STP< $STRING{ETP}} < $STRING{ETP}, $SEARCH{ETP,STP}, $BINARY is -- This abstract class characterises all forms of string whether binary, -- text or other. The implementations of this class shall provide immutable -- semantics! -- Version 1.4 Nov 2000. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 19 Dec 96 kh Original -- 29 Apr 97 kh Modified to have parent $STRINGS! -- 22 Dec 97 kh Included 'filability'! -- 8 Apr 99 kh Modified for Version 8 of text classes -- 28 Nov 00 kh Simplified inheritance plus(elem : ETP) : SAME ; -- This returns the string formed by appending other (which must be of -- the same class) to self. Either or both may be void. plus(str : STP) : SAME ; -- This returns the string formed by appending other (which must be of -- the same class) to self. Either or both may be void. plus(str : FSTP) : SAME ; -- This returns the string formed by appending other (which must be of -- the same class) to self. Either or both may be void. reverse : SAME ; -- This routine returns a string which has the value of self with all -- elements in the reverse order. elt!(once beg : CARD ) : ETP ; -- This iter yields each element of the string in sequence starting with -- that indicated by the index beg. elt!(once beg,once num : CARD) : ETP ; -- This iter yields num elements of self in sequence, starting with that -- indicated by the index beg. chunk!(chunk_size : CARD) : SAME ; -- This iter yields successive groups of elements of self, the length -- of which is defined by the chunk_size parameter. chunk!(once start : CARD,chunk_size : CARD) : SAME ; -- This iter yields successive groups of elements starting at start, -- the length of which is defined by the chunk_size parameter. end ; -- $STRING{ETP, STP, FSTP}

abstract class $TEXT_STRING{ETP < $IS_EQ} < $STRING{ETP}

abstract class $TEXT_STRING{ETP < $IS_EQ} < $STRING{ETP} is -- This abstract class characterises all forms of string whether binary, -- text or other. The implementations of this class shall provide immutable -- semantics! -- Version 1.1 Nov 2000. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 20 Apr 99 kh Modified for Version 8 of text classes -- 28 Nov 00 kh Simplified inheritance index_lib : LIBCHARS ; -- This reader/writer feature returns the repertoire and encoding -- associated with self. create(val : ETP) : SAME ; -- This creation routine returns a new text string consisting of the -- single element given. end ; -- $TEXT_STRING{ETP}

abstract class $TEXT_STRING{ETP < $IS_EQ, FSTP < $FTEXT_STRING{ETP}, STP < $TEXT_STRING{ETP}}

abstract class $TEXT_STRING{ETP < $IS_EQ, FSTP < $FTEXT_STRING{ETP}, STP < $TEXT_STRING{ETP}} < $TEXT_STRING{ETP}, $SEARCH{ETP,STP}, $BINARY is -- This abstract class characterises all forms of string whether binary, -- text or other. The implementations of this class shall provide immutable -- semantics! -- Version 1.1 Nov 2000. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 8 Apr 99 kh Original for Version 8 of text classes -- 29 Nov 00 kh Simplified inheriutance, added create. create(code : CHAR_CODE) : SAME ; -- This form of creation is necessary for all forms of text string to -- create a single element string from its character code. build(cursor : BIN_CURSOR,lib : LIBCHARS) : SAME ; -- This routine builds the string from the binary string indicated using -- the encoding and repertoire defined by lib. If the string indicated by -- cursor does not contain an integral number of character codes in the given -- repertoire and encoding then void is returned and the cursor has not been -- moved. is_upper : BOOL ; -- This predicate returns true if and only if every character of self is -- upper-case, otherwise false. is_lower : BOOL ; -- This predicate returns true if and only if every character of self is -- lower-case, otherwise false. char(index : CARD) : ETP ; -- This routine returns the character to be found at the indicated -- element of self, or void if there is no such character. upper : SAME ; -- This routine returns a copy of self in which every lower case -- character is converted to its upper case equivalent. lower : SAME ; -- This routine returns a copy of self in which every upper case -- character is converted to its lower case equivalent. capitalize : SAME ; -- This routine returns a copy of self in which the first character of -- every word (from the beginning of the string or after punctuation or -- a whitespace) is converted to its upper case equivalent. repeat(cnt : CARD) : SAME ; -- This routine returns a new string which contains the contents of -- self repeated cnt times. replace(old_ch,new_ch : ETP) : SAME ; -- This routine returns a new string which is a copy of self apart from -- which each occurrence of old_ch has been replaced by new_ch. replace(set : STP,new_ch : ETP) : SAME ; -- This routine returns a copy of self in which all occurrences of -- any character in set are replaced by new_ch. remove(ch : ETP) : SAME ; -- This routine returns a copy of self with all occurrences of ch removed. remove(str : STP) : SAME ; -- This routine returns a copy of self from which all characters -- contained in str have been removed. escape(esc : ETP,elist : STP) : SAME ; -- This routine returns a copy of self in which all characters occurring -- in elist - and the character esc itself - are preceded by the escape character. strip : SAME ; -- This routine strips any number of contiguous line_marks from the end -- of self -- if present -- returning the result. minus(str : STP) : SAME ; -- This routine returns a copy of self with the first (if any) -- occurrence of str deleted. minus(str : STP, start : CARD) : SAME ; -- This routine returns a copy of self in which the first occurrence -- of str after the given start index (if any) is deleted. rev! : ETP ; -- This iter yields the elements of self in reverse order. code! : CHAR_CODE ; -- This iter yields each individual character encoding in self -- in sequence using the code specified repertoire and encoding. code!(once start_code : CARD) : CHAR_CODE ; -- This iter yields each individual character encoding in self -- in sequence. end ; -- $TEXT_STRING{ETP, FSTP, STP}