[SLP-Homepage]    [Source Modules]    [Manual]    [Run]    [Examples]
 

Character Classes

This module contains character classification functions, very similar to the macros from "ctype.h". Differences are as follows:

Currently, this module is realized as a class ch_c with some class functions. It is not possible to create instances of this class.

Note that the class method init must be called before any of the other functions.


Character Classes:

The enumeration type ch_t defines the possible character classes:


Initialisation:
init:
void init(void);
This function must be called before any other function of this module. It initializes the class variables.


Character Classification:
classify:
static ch_t classify(char c);
This function returns the character class of an input character.
is_alnum:
static bool_t is_alnum(char_c);
This function returns BOOL_TRUE iff the input character is a letter (including national ones), a digit, or the underscore character ("_"). Otherwise, BOOL_FALSE is returned.
is_space:
static bool_t is_space(char c);
This function returns BOOL_TRUE iff the input character is a "white space" character, i.e. a space, a tabulator, or a carriage return. Note that a linefeed is not treated as white space here.
is_comment:
static bool_t is_comment(char c);
This function returns BOOL_TRUE if the input character indicates a begin of a comment. Currently, this is the character "%".
is_newline:
static bool_t is_newline(char c);
This function returns BOOL_TRUE iff the input character is the linefeed character.
is_quote:
static bool_t is_quote(char c);
This function returns BOOL_TRUE if the input character is a quotation character ("'") used in quoted atoms.
is_undersc:
static bool_t is_undersc(char c);
This function returns BOOL_TRUE iff the input character is the underscore character ("_"). The underscore character is special because of the anonymous variable.
ord:
static int ord(char c);
This function returns the position of the input character in some "alphabet". The absolute value has no significance, but comparing the ord-values of two characters should give the correct order. Uppercase and lowercase characters return the same value (whereas, if the ASCII sequence would be used, all uppercase characters come before all lowercase characters). Also, national characters with accents (like "äöü") return the same values as the corresponding normal characters (i.e. "aou").
xord:
static int xord(char c);
Some national characters must be sorted like a two character sequence. For instance, the German letter "ß" must be treated like "ss" for correct alphabetical sorting. In this case, ord returns the position of the first character and xord returns the position of the second character. For normal characters, xord returns 0.


Implementation:


Stefan Brass (sbrass@sis.pitt.edu), March 02, 2002.    [HTML 3.2 Checked]