Package lepl :: Package regexp :: Module str :: Class StrParser
[hide private]
[frames] | no frames]

Class StrParser

source code


Construct a parser for string based expressions.

We need a clear policy on backslashes. To be as backwards compatible as possible I am going with:

  1. "Escaping" means prefixing with .
  2. These characters are special: {, }, [, ], -, , (, ), *, ?, ., +, ^, $, |.
  3. Special characters (ie literal, or unescaped special characters) may not have a meaning currently, or may only have a meaning in certain contexts.
  4. To use a special character literally, it must be escaped.
  5. If a special character is used without an escape, in a context where it doesn't have a meaning, then it is an error.
  6. If a non-special character is escaped, that is also an error.

This is not the same as the Python convention, but I believe it makes automatic escaping of given text easier.

Instance Methods [hide private]
 
__init__(self, alphabet)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
dup(self, x)
Create an interval from a single character.
source code
 
tup(self, x)
Create an interval from a tuple.
source code
 
dot(self, _)
Create a "complete" interval.
source code
 
invert(self, x)
Invert an interval.
source code
 
sequence(self, x)
Create a sequence.
source code
 
star(self, x)
Repeat a sub-expression.
source code
 
plus(self, x)
Repeat a sub-expression.
source code
 
option(self, x)
Make a sub-expression optional.
source code
 
choice(self, x)
Construct a choice from a list of sub-expressions.
source code
 
char(self, x)
Construct a character from an interval (pair).
source code
 
extend(self, x)
Delegate a character extension to the alphabet.
source code
 
build(self)
Construct the parser.
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, alphabet)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)