abschars.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 $CHAR{TYP} < $ORDERED{TYP}, $HASH, $BINARY, $ANCHORED_FMT
abstract class $CHAR{TYP} < $ORDERED{TYP}, $HASH, $BINARY, $ANCHORED_FMT is
-- This abstraction models the semantic notion of a character, ascribing
-- to it all of those features which are not dependent upon any particular
-- form of representation. One additional implementation feature is,
-- however, added - the number of codes in the character.
-- Version 1.1 Apr 99. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 21 Feb 99 kh Original
-- 9 Apr 99 kh Revised for Version 8 of text classes
create(
code : CHAR_CODE
) : SAME ;
-- This routine creates a character from a single character code - which
-- must NOT be a combining code.
create(
code : CONTROL_CODES,
lib : LIBCHARS
) : SAME ;
-- This creates a 'control character' (ie a character, the code of which
-- has been assigned a specific function when found by some representation
-- engine in a character stream - for example, a line mark or tab function)
-- from the given control code!
null : SAME ;
-- This routine returns the character corresponding to the control
-- function name NUL.
char : CHAR ;
-- This routine returns the character corresponding to self unless self
-- contains more than one encoding when void is returned.
code(
lib : LIBCHARS
) : CHAR_CODE ;
-- This routine returns the character code corresponding to (the first
-- element of) self - which is given the indicated repertoire and encoding.
code : CHAR_CODE ;
-- This routine returns the character code corresponding to (the first
-- element of) self - which is presumed to be in the default repertoire and
-- encoding.
rune(
lib : LIBCHARS
) : RUNE ;
-- This routine returns the rune corresponding to self which is presumed
-- to be in the given repertoire and encoding.
rune : RUNE ;
-- This routine returns the rune corresponding to self in the default
-- repertoire and encoding.
is_alpha(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is defined as an
-- alphabetic character in the given character repertoire. Note that this may
-- be identically false for some scripts.
is_alpha : BOOL ;
-- This routine returns true if and only if self is defined as an
-- alphabetic character by the character repertoire and script in use. Note
-- that this may be identically false for some scripts.
is_upper(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is defined as an upper
-- case (capital) alphabetic character in the given character repertoire.
-- Note that this may be identically false for some scripts.
is_upper : BOOL ;
-- This routine returns true if and only if self is defined as an upper
-- case (capital) alphabetic character by the character repertoire and script
-- in use. Note that this may be identically false for some scripts.
is_lower(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is defined as a lower
-- case (small) alphabetic character in the given character repertoire. Note
-- that this may be identically false for some scripts.
is_lower : BOOL ;
-- This routine returns true if and only if self is defined as a lower
-- case (small) alphabetic character by the character repertoire and script
-- in use. Note that this may be identically false for some scripts.
is_octal_digit(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is an octal digit
-- character in the given character repertoire.
is_octal_digit : BOOL ;
-- This routine returns true if and only if self is an octal digit
-- character.
is_digit(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is a decimal digit in
-- the given character repertoire.
is_digit : BOOL ;
-- This routine returns true if and only if self is a decimal digit.
is_hex_digit(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is a hexadecimal digit
-- in the given character repertoire.
is_hex_digit : BOOL ;
-- This routine returns true if and only if self is a hexadecimal digit.
is_numeric(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is a number, whether or
-- not this is also a digit. If there are digits in the given character
-- repertoire and script then they are a subset of the characters for which
-- this routine would return true.
is_numeric : BOOL ;
-- This routine returns true if and only if self is a number, whether or
-- not this is also a digit. If there are digits in the character
-- repertoire and script then they are a subset of the characters for which
-- this routine would return true.
is_alphanum(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is a character which
-- represents either a letter or a digit in the given character repertoire.
-- Note that this excludes characters for which is_numeric would return true
-- and is_digit false!
is_alphanum : BOOL ;
-- This routine returns true if and only if self is a character which
-- represents either a letter or a digit. Note that this excludes
-- characters for which is_numeric would return true and is_digit false!
is_space(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is either a white-space
-- character in the given character repertoire or it is a control code
-- signifying a move of the current position in the document without making
-- a visible mark, otherwise false.
is_space : BOOL ;
-- This routine returns true if and only if self is either a white-space
-- character or is a control code signifying a move of the current position
-- in the document without making a visible mark, otherwise false.
is_print(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if the self corresponds to
-- some visible glyph in the given character repertoire, otherwise false.
is_print : BOOL ;
-- This routine returns true if and only if the self corresponds to
-- some visible glyph, otherwise false.
is_punct(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is a character which
-- would be interpreted as punctuation in the given character repertoire.
is_punct : BOOL ;
-- This routine returns true if and only if self is a character which
-- would be interpreted as punctuation in the culture repertoire in use.
is_control(
lib : LIBCHARS
) : BOOL ;
-- This routine returns true if and only if self is a control code in
-- the given character repertoire
is_control : BOOL ;
-- For those repertoires which include control codes, this routine will
-- return true if and only if self is such a control code, otherwise false.
num_codes : CARD ;
-- This feature gives the number of individual encodings forming
-- the character.
upper(
lib : LIBCHARS
) : SAME ;
-- Providing that there exists an upper case version of self in the
-- given repertoire and encoding then that upper case character is returned,
-- otherwise self.
upper : SAME ;
-- Providing that there exists an upper case version of self in the
-- default repertoire and encoding then that upper case character is
-- returned, otherwise self.
lower(
lib : LIBCHARS
) : SAME ;
-- Providing that there exists a lower case version of self in the given
-- repertoire and encoding then that lower case character is returned,
-- otherwise self.
lower : SAME ;
-- Providing that there exists a lower case version of self in the
-- default repertoire and encoding then that lower case character is
-- returned, otherwise self.
octal_digit_value(
lib : LIBCHARS
) : CARD ;
-- This routine returns the numeric value corresponding to the
-- octal digit represented by self in the given repertoire and encoding.
octal_digit_value : CARD ;
-- This routine returns the numeric value corresponding to the
-- octal digit represented by self in the default repertoire and encoding.
digit_value(
lib : LIBCHARS
) : CARD ;
-- This routine returns the numeric value corresponding to the
-- digit character represented by self in the given repertoire and encoding.
digit_value : CARD ;
-- This routine returns the numeric value corresponding to the
-- digit character represented by self in the default repertoire and encoding.
hex_digit_value(
lib : LIBCHARS
) : CARD ;
-- This routine returns the numeric value corresponding to the
-- hexadecimal digit character represented by self in the given repertoire
-- and encoding.
hex_digit_value : CARD ;
-- This routine returns the numeric value corresponding to the
-- hexadecimal digit character represented by self in the default repertoire
-- and encoding.
code!(
once lib : LIBCHARS
) : CHAR_CODE ;
-- This iter yields successive encodings of self (which may, of course,
-- be only one!) in the given repertoire and encoding.
code! : CHAR_CODE ;
-- This iter yields successive encodings of self (which may, of course,
-- be only one!) in the default encoding and repertoire.
end ; -- $CHAR
partial class CHAR_INCL
partial class CHAR_INCL is
-- This partial class implements those character class routines which
-- are common to characters with single encodings and those with multiple
-- encodings.
-- Version 1.1 Apr 99. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 21 Feb 99 kh Original during efficiency drive!
-- 9 Apr 99 kh Revised for version 8 of text classes
stub build(
cursor : BIN_CURSOR,
lib : LIBCHARS
) : SAME ;
-- This routine takes the number of octets required to form a single
-- encoding in the indicated repertoire and encoding, returning the resultant
-- character.
stub build(
cursor : BIN_CURSOR
) : SAME ;
-- This routine takes the number of octets required to form a single
-- encoding in the default repertoire and encoding, returning the resultant
-- character.
stub valid(
num : CARD,
lib : LIBCHARS
) : BOOL ;
-- This predicate returns true if and only if num is a valid bit-pattern
-- for a character code in the given encoding and repertoire.
stub valid(
num : CARD
) : BOOL ;
-- This predicate returns true if and only if num is a valid bit-pattern
-- for a character code in the default encoding and repertoire.
stub binstr : BINSTR ;
-- This routine returns the value of self as a binary string. This does
-- not include any repertoire or encoding information!
stub is_eq(
other : SAME
) : BOOL ;
-- This routine returns true if and only if self and other are the same
-- character irrespective of encoding!!
stub is_lt(
other : SAME
) : BOOL ;
-- This routine returns true if and only if self is earlier than other
-- in the repertoire defined ordering of characters.
-- NOTE All of the predicates and value conversions ignore any
-- preliminary combining characters, which do not affect
-- the result!
is_alpha(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is defined as an
-- alphabetic character by the script in use for the given encoding and
-- repertoire. Note that for some repertoires and encodings this may be
-- identically false.
return CHAR_CLASS::Alphabetic.contains(self.code(lib).char,lib)
end ;
is_alpha : BOOL is
-- This routine returns true if and only if self is defined as an
-- alphabetic character by the script in use for this encoding. Note that
-- for some repertoires and encodings this may be identically false.
return is_alpha(LIBCHARS::default)
end ;
is_downmapped(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is an upper case
-- character and there is a valid mapping to an equivalent lower case
-- letter.
loc_ch : CHAR := self.code(lib).char ;
return CHAR_CLASS::Upper_Case.contains(loc_ch,lib)
and CHAR_MAPPINGS::To_Lower.is_mapped(loc_ch,lib.culture)
end ;
is_downmapped : BOOL is
-- This predicate returns true if and only if self is an upper case
-- character and there is a valid mapping to an equivalent lower case
-- letter in the default culture and environment.
return is_downmapped(LIBCHARS::default)
end ;
is_upper(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is defined as an
-- upper case (capital) alphabetic character by the script in use for this
-- encoding. Note that for some repertoires and encodings this may be
-- identically false.
return CHAR_CLASS::Upper_Case.contains(self.code(lib).char,lib)
end ;
is_upper : BOOL is
-- This routine returns true if and only if self is defined as an
-- upper case (capital) alphabetic character by the script in use for this
-- encoding. Note that for some repertoires and encodings this may be
-- identically false.
return is_upper(LIBCHARS::default)
end ;
is_upmapped(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is a lower case
-- character and there is a valid mapping to an equivalent upper case
-- letter.
loc_ch : CHAR := self.code(lib).char ;
return CHAR_CLASS::Lower_Case.contains(loc_ch,lib)
and CHAR_MAPPINGS::To_Upper.is_mapped(loc_ch,lib.culture)
end ;
is_upmapped : BOOL is
-- This routine returns true if and only if self is a lower case
-- character and there is a valid mapping to an equivalent upper case
-- letter in the default culture and environment.
return is_upmapped(LIBCHARS::default)
end ;
is_lower(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is defined as a
-- lower case (small) alphabetic character by the script in use for this
-- encoding. Note that for some repertoires and encodings this may be
-- identically false.
return CHAR_CLASS::Lower_Case.contains(self.code(lib).char,lib)
end ;
is_lower : BOOL is
-- This routine returns true if and only if self is defined as a
-- lower case (small) alphabetic character by the script in use for this
-- encoding. Note that for some repertoires and encodings this may be
-- identically false.
return is_lower(LIBCHARS::default)
end ;
is_octal_digit(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is an encoding for
-- an octal digit character.
return CHAR_CLASS::Digit.contains(char,lib)
and (lib.card(char) < OCTET::Octet_Bits)
end ;
is_octal_digit : BOOL is
-- This routine returns true if and only if self is an encoding for
-- an octal digit character.
return is_octal_digit(LIBCHARS::default)
end ;
is_digit(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self isan encoding for a
-- decimal digit in the given repertoire and encoding, otherwise false.
return CHAR_CLASS::Digit.contains(self.code(lib).char,lib)
end ;
is_digit : BOOL is
-- This routine returns true if and only if self has an encoding for a
-- decimal digit, otherwise false.
return is_digit(LIBCHARS::default)
end ;
is_hex_digit(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self has an encoding for a
-- hexadecimal digit, otherwise false.
return CHAR_CLASS::Hex_Digit.contains(self.code(lib).char,lib)
end ;
is_hex_digit : BOOL is
-- This routine returns true if and only if self is an encoding for a
-- hexadecimal digit in the default repertoire and encoding, otherwise false.
return is_hex_digit(LIBCHARS::default)
end ;
is_numeric(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is an encoding which
-- represents a number, whether or not this is also a digit. If there are
-- digits in the encoding then they are a subset of the encodings for which
-- this routine would return true.
return CHAR_CLASS::Numeric.contains(self.code(lib).char,lib)
end ;
is_numeric : BOOL is
-- This routine returns true if and only if self is an encoding which
-- represents a number, whether or not this is also a digit. If there are
-- digits in the encoding then they are a subset of the encodings for which
-- this routine would return true.
return is_numeric(LIBCHARS::default)
end ;
is_alphanum(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is an encoding (in
-- the given repertoire and encoding) which represents either an alphabetic
-- letter or a number.
return is_numeric(lib)
or is_alpha(lib)
end ;
is_alphanum : BOOL is
-- This routine returns true if and only if self is an encoding (in
-- the default repertoire and encoding) which represents either a number or
-- a digit.
return is_alphanum(LIBCHARS::default)
end ;
is_space(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if self is either a white-space
-- character or is a control code signifying a move of the current position
-- in the document without making a visible mark, otherwise false.
return CHAR_CLASS::Space.contains(self.code(lib).char,lib)
end ;
is_space : BOOL is
-- This routine returns true if and only if self is either a white-space
-- character or is a control code signifying a move of the current position
-- in the document without making a visible mark, otherwise false.
return is_space(LIBCHARS::default)
end ;
is_print(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- This routine returns true if and only if the encoding corresponds to
-- some visible glyph or part thereof (eg a combining code), otherwise false.
return CHAR_CLASS::Printable.contains(self.code(lib).char,lib)
end ;
is_print : BOOL is
-- This routine returns true if and only if the encoding corresponds to
-- some visible glyph or part thereof (eg a combining code), otherwise false.
return is_print(LIBCHARS::default)
end ;
is_punct(
lib : LIBCHARS
) : BOOL
pre ~void(lib)
post true
is
-- this routine returns true if and only if self represents a character
-- which would be interpreted as punctuation in the encoding in use.
return CHAR_CLASS::Punctuation.contains(self.code(lib).char,lib)
end ;
is_punct : BOOL is
-- this routine returns true if and only if self represents a character
-- which would be interpreted as punctuation in the encoding in use.
return is_punct(LIBCHARS::default)
end ;
is_control(
lib : LIBCHARS
) : BOOL
pre ~void(lib) -- should be ~void(self) too!!
post true
is
-- For those repertoires which include control codes, this routine will
-- return true if and only if self is such a control code, otherwise false.
return CHAR_CLASS::Control.contains(self.code(lib).char,lib)
end ;
is_control : BOOL is
-- For those repertoires which include control codes, this routine will
-- return true if and only if self is such a control code, otherwise false.
return is_control(LIBCHARS::default)
end ;
octal_digit_value(
lib : LIBCHARS
) : CARD
pre is_octal_digit(lib)
post (result < OCTET::Octet_Bits)
is
-- This routine returns either the numeric value corresponding to the
-- octal digit encoding given.
return lib.oct_card(self.code(lib).char)
end ;
octal_digit_value : CARD
pre is_octal_digit
post (result < OCTET::Octet_Bits)
is
-- This routine returns either the numeric value corresponding to the
-- octal digit encoding given.
return octal_digit_value(LIBCHARS::default)
end ;
digit_value(
lib : LIBCHARS
) : CARD
pre is_digit(lib)
post result < 10
is
-- This routine returns either the numeric value corresponding to the
-- digit encoding given or, if the character is not a digit, the value
-- CARD::nil which is itself not a digit value.
return lib.card(self.code(lib).char)
end ;
digit_value : CARD
pre self.is_digit
post result < 10
is
-- This routine returns either the numeric value corresponding to the
-- digit encoding given or, if the character is not a digit, the value
-- CARD::nil which is itself not a digit value.
return digit_value(LIBCHARS::default)
end ;
hex_digit_value(
lib : LIBCHARS
) : CARD
pre self.is_hex_digit(lib)
post result < 16
is
-- This routine returns either the numeric value corresponding to the
-- hexadecimal digit encoding given.
return lib.hex_card(self.code(lib).char)
end ;
hex_digit_value : CARD
pre self.is_hex_digit
post result < 16
is
-- This routine returns either the numeric value corresponding to the
-- hexadecimal digit encoding given.
return hex_digit_value(LIBCHARS::default)
end ;
end ; -- CHAR_INCL