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

Type TokenSequence

   object --+    
            |    
AbstractToken --+
                |
ListReplacing --+
                |
               TokenSequence

Known Subclasses:
Oper

A class whose instances match a sequence of tokens. Returns a corresponding list of return values from ZestyParser.scan.

Some special types, Skip, Omit, and Only, are allowed in the sequence. These are wrappers for other token objects adding special behaviours. If it encounters a Skip token, it will process it with ZestyParser.skip, ignore whether it matched, and not include it in the list. If it encounters a Omit token, it will still require that it match (the default behaviour), but it will not be included in the list.

If the sequence contains an Only token, its result will be returned instead of the usual list, though it still requires that subsequent tokens match. Multiple Only tokens are meaningless and TokenSequence's behavior in that case is undefined.
Method Summary
  __add__(self, other)
Allows you to construct TokenSequences with the + operator.
  __call__(self, parser, origCursor)
  __iadd__(self, other)
  __str__(self)
  __sub__(self, other)
Allows you to construct TokenSequences with the - operator, automatically padded with Whitespace.
    Inherited from ListReplacing
  _replace(self, vals, kwvals)
    Inherited from AbstractToken
  __init__(self, desc, callback, to, as, name)
  __copy__(self)
  __imod__(self, val)
  __invert__(self)
  __mod__(self, val)
  __mul__(self, val)
Allows you to construct TokenSeries with the * operator.
  __or__(self, other)
Allows you to construct CompositeTokens with the | operator.
  __repr__(self)
  __rmul__(self, val)
Allows you to construct TokenSeries with the * operator.
  __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 |.
  __setattr__(self, name, value)
  __xor__(self, message)
Overloading for setting the failMessage of a token.
  _make_callbackrun(self, func, callback)
  _make_failcheck(self, func)
  _make_torun(self, func)
  _poke(self)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle

Instance Variable Summary
list desc: A list of token objects.
    Inherited from AbstractToken
NoneType callback: An optional callable which, if not None, will be called whenever an instance matches successfully.
NoneType to: 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).

Class Variable Summary
    Inherited from AbstractToken
NoneType failMessage = None                                                                  
NoneType name = None                                                                  

Method Details

__add__(self, other)
(Addition operator)

Allows you to construct TokenSequences with the + operator.
Overrides:
ZestyParser.Tokens.AbstractToken.__add__ (inherited documentation)

__sub__(self, other)
(Subtraction operator)

Allows you to construct TokenSequences with the - operator, automatically padded with Whitespace.

I realize it's a bit weird to use the - operator for this, but the main motivation is giving it the same precedence as +. Still, you can read it as a sort of "blank" (which is what the left and right tokens are being joined by), instead of "minus".
Overrides:
ZestyParser.Tokens.AbstractToken.__sub__ (inherited documentation)

Instance Variable Details

desc

A list of token objects.
Type:
list

Generated by Epydoc 2.1 on Thu Apr 26 01:32:22 2007 http://epydoc.sf.net