Package lepl :: Package regexp :: Module core :: Class Alphabet
[hide private]
[frames] | no frames]

Class Alphabet

source code


Regular expressions are generalised over alphabets, which describe the set of acceptable characters.

The characters in an alphabet must have an order, which is defined by __lt__ on the character instances themselves (equality and inequality are also assumed to be defined). In addition, before(c) and after(c) below should give the previous and subsequent characters in the ordering and min and max should give the two most extreme characters.

Internally, within the routines here, ranges of characters are used. These are encoded as pairs of values (a, b) which are inclusive. Each pair is called an "interval".

Alphabets include additional methods used for display and may also have methods specific to a given instance (typically named with an initial underscore).

Instance Methods [hide private]
 
__init__(self, min_, max_)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
min(self)
The "smallest" character.
source code
 
max(self)
The "largest" character.
source code
 
before(self, c)
Must return the character before c in the alphabet.
source code
 
after(self, c)
Must return the character after c in the alphabet.
source code
 
fmt_intervals(self, intervals)
This must fully describe the data in the intervals (it is used to hash the data).
source code
 
invert(self, intervals)
Return a list of intervals that describes the complement of the given interval.
source code
 
extension(self, text)
This is called for extensions for the form (NAME) where NAME is any sequence of capitals. It should return a character range. Further uses of (...) are still to be decided.
source code
 
fmt_sequence(self, children)
This must fully describe the data in the children (it is used to hash the data).
source code
 
fmt_repeat(self, children)
This must fully describe the data in the children (it is used to hash the data).
source code
 
fmt_choice(self, children)
This must fully describe the data in the children (it is used to hash the data).
source code
 
fmt_option(self, children)
This must fully describe the data in the children (it is used to hash the data).
source code
 
fmt_label(self, label, child)
This must fully describe the data in the child (it is used to hash the data).
source code
 
join(self, chars)
Join a list of characters into a string (or the equivalent).
source code
 
parse(self, regexp)
Generate a Sequence from the given regexp text.
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 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

min(self)

source code 
The "smallest" character.
Decorators:
  • @property

max(self)

source code 
The "largest" character.
Decorators:
  • @property

before(self, c)

source code 
Must return the character before c in the alphabet. Never called with min (assuming input data are in range).
Decorators:
  • @abstractmethod

after(self, c)

source code 
Must return the character after c in the alphabet. Never called with max (assuming input data are in range).
Decorators:
  • @abstractmethod

fmt_intervals(self, intervals)

source code 
This must fully describe the data in the intervals (it is used to hash the data).
Decorators:
  • @abstractmethod

invert(self, intervals)

source code 
Return a list of intervals that describes the complement of the given interval. Note - the input interval must be ordered (and the result will be ordered too).

fmt_sequence(self, children)

source code 
This must fully describe the data in the children (it is used to hash the data).
Decorators:
  • @abstractmethod

fmt_repeat(self, children)

source code 
This must fully describe the data in the children (it is used to hash the data).
Decorators:
  • @abstractmethod

fmt_choice(self, children)

source code 
This must fully describe the data in the children (it is used to hash the data).
Decorators:
  • @abstractmethod

fmt_option(self, children)

source code 
This must fully describe the data in the children (it is used to hash the data).
Decorators:
  • @abstractmethod

fmt_label(self, label, child)

source code 
This must fully describe the data in the child (it is used to hash the data).
Decorators:
  • @abstractmethod

join(self, chars)

source code 
Join a list of characters into a string (or the equivalent).
Decorators:
  • @abstractmethod

parse(self, regexp)

source code 
Generate a Sequence from the given regexp text.
Decorators:
  • @abstractmethod