Package rxpy :: Package alphabet :: Module base :: Class BaseAlphabet
[hide private]
[frames] | no frames]

Class BaseAlphabet

source code


Defines the interface that all alphabets must implement.

An alphabet assumes that there's a mapping between "characters" and integers, such that each character maps to a separate value in a contiguous region between min and max. This defines an ordering that is used, for example, to infer the content of character ranges.

Instance Methods [hide private]
 
__init__(self, min, max)
min and max define the range of values that char_to_code will map characters to (inclusive).
source code
 
code_to_char(self, code)
Convert a code - an integer value between min and max, that maps the alphabet to a contiguous set of integers - to a character in the alphabet.
source code
 
char_to_code(self, char)
Convert a character in the alphabet to a code - an integer value between min and max, that maps the alphabet to a contiguous set of integers.
source code
 
coerce(self, char)
Force a character in str, unicode, or the alphabet itself, to be a member of the alphabet.
source code
 
join(self, *strings)
Construct a word in the alphabet, given a list of words and/or characters.
source code
 
to_str(self, char)
Support display of the character.
source code
 
after(self, char)
The character "before" the given one, or None
source code
 
before(self, char)
The character "before" the given one, or None
source code
 
digit(self, char)
Test whether the character is a digit or not.
source code
 
space(self, char)
Test whether the character is a whitespace or not.
source code
 
word(self, char)
Test whether the character is a word character or not.
source code
 
unpack(self, char, flags)
Return either (True, CharSet) or (False, char)
source code
 
unescape(self, code)
By default, assume escape codes map to character codes.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, min, max)
(Constructor)

source code 
min and max define the range of values that char_to_code will map characters to (inclusive).
Overrides: object.__init__

code_to_char(self, code)

source code 
Convert a code - an integer value between min and max, that maps the alphabet to a contiguous set of integers - to a character in the alphabet.
Decorators:
  • @unimplemented

char_to_code(self, char)

source code 
Convert a character in the alphabet to a code - an integer value between min and max, that maps the alphabet to a contiguous set of integers.
Decorators:
  • @unimplemented

coerce(self, char)

source code 
Force a character in str, unicode, or the alphabet itself, to be a member of the alphabet.
Decorators:
  • @unimplemented

join(self, *strings)

source code 
Construct a word in the alphabet, given a list of words and/or characters.
Decorators:
  • @unimplemented

to_str(self, char)

source code 

Support display of the character.

Note - this is the basis of hash and equality for intervals, so must be unique, repeatable, etc.

Decorators:
  • @unimplemented