Class TokenSequence
AbstractToken
--+
|
TokenSequence
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 TokenSequence s with the + operator. |
|
__call__(self,
parser,
origCursor)
|
|
__iadd__(self,
other)
|
|
__str__(self)
|
Inherited from AbstractToken |
|
__init__ (self,
desc,
callback,
to,
as,
name)
|
|
__copy__ (self)
|
|
__invert__ (self)
|
|
__or__ (self,
other)
Allows you to construct CompositeToken s 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 | . |
|
__setattr__ (self,
name,
value)
|
|
__xor__ (self,
message)
Overloading for setting the failMessage of a token. |
Instance Variable Summary |
iterable |
desc : An iterable returning 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). |
Instance Variable Details |
desc
An iterable returning token objects.
-
- Type:
-
iterable
|