Package ZestyParser :: Module Tokens :: Class TokenSeries
[show private | hide private]
[frames | no frames]

Class TokenSeries

AbstractToken --+
                |
               TokenSeries


A particularly versatile class whose instances match one token multiple times.

The properties skip, prefix, postfix, and delimiter are optional tokens which add structure to the series. It can be represented, approximately in the idioms of TokenSequence, as follows:
       [Skip(skip) + Omit(prefix) + desc + Omit(postfix)] + [Skip(skip) + Omit(delimiter) + Skip(skip) + Omit(prefix) + desc + Omit(postfix)] + ... + Skip(skip)
Or, if there is no delimiter:
       [Skip(skip) + Omit(prefix) + desc + Omit(postfix)] + ... + Skip(skip)

Method Summary
  __init__(self, token, min, max, skip, prefix, postfix, delimiter, until, includeDelimiter, callback, as, name)
  __call__(self, parser, origCursor)
    Inherited from AbstractToken
  __add__(self, other)
Allows you to construct TokenSequences with the + operator.
  __or__(self, other)
Allows you to construct CompositeTokens with the | operator.
  __repr__(self)
  __rshift__(self, callback)
Convenience overloading for setting the callback of a token whose initializer you do not call directly, such as the result of combining tokens with + or |.
  __xor__(self, message)
Overloading for setting the failMessage of a token.
  preprocessResult(self, parser, data, origCursor)
Method called by subclasses' __call__ methods to add uniform support for the callback and as parameters.

Instance Variable Summary
token delimiter: An optional token to require (but omit from the return value) between each instance of token.
token desc: The token to match.
int max: The maximum number of times desc will try to match.
int min: The minimum number of times desc must match.
token postfix: An optional token to require (but omit from the return value) after each instance of token.
token prefix: An optional token to require (but omit from the return value) before each instance of token.
token skip: An optional token to skip between matches.
  until: An optional 2-tuple whose first item is a token, and whose second item is either a message or False.
    Inherited from AbstractToken
  as: An optional callable which, if not None, will be called in the same manner as a callback (after any callback and before returning to the parser instance), but will be passed only one argument: the data matched (or returned by the callback, if any).
  callback: An optional callable which, if not None, will be called whenever an instance matches successfully.

Class Variable Summary
    Inherited from AbstractToken
NoneType failMessage = None                                                                  

Instance Variable Details

delimiter

An optional token to require (but omit from the return value) between each instance of token.
Type:
token

desc

The token to match.
Type:
token

max

The maximum number of times desc will try to match.
Type:
int

min

The minimum number of times desc must match.
Type:
int

postfix

An optional token to require (but omit from the return value) after each instance of token.
Type:
token

prefix

An optional token to require (but omit from the return value) before each instance of token.
Type:
token

skip

An optional token to skip between matches.
Type:
token

until

An optional 2-tuple whose first item is a token, and whose second item is either a message or False. The presence of this property indicates that the token in until[0] must match at the end of the series. If this fails, then if until[1] is a message, a ParseError will be raised with that message; if it is False, NotMatched will be raised.

Generated by Epydoc 2.1 on Thu Jan 11 23:26:09 2007 http://epydoc.sf.net