Home | Trees | Index | Help |
---|
Package ZestyParser :: Module Tokens :: Class AbstractToken |
|
CompositeToken
,
Default
,
Defer
,
Lookahead
,
Negative
,
Omit
,
RawToken
,
Skip
,
TakeToken
,
Token
,
TokenSequence
,
TokenSeries
,
TokenWrapper
,
_EOF
Method Summary | |
---|---|
__init__(self,
desc,
callback,
to,
as,
name)
| |
Allows you to construct TokenSequence s with the + operator. | |
__copy__(self)
| |
__invert__(self)
| |
Allows you to construct CompositeToken s with the | operator. | |
__repr__(self)
| |
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)
| |
__str__(self)
| |
Overloading for setting the failMessage of a token. | |
_call_failcheck(self,
parser,
origCursor)
| |
_call_preprocess(self,
parser,
origCursor)
|
Instance Variable Summary | |
---|---|
NoneType |
callback : An optional callable which, if not None, will be called whenever an
instance matches successfully. |
desc : The generic "description" variable which stores the
"essence" of any given instance. | |
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 | |
---|---|
bool |
callbackArgCount = False
|
NoneType |
failMessage = None |
NoneType |
_call_orig = None |
Method Details |
---|
__add__(self,
other)
Allows you to construct |
__or__(self,
other)
Allows you to construct |
__rshift__(self, callback)Convenience overloading for setting thecallback 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 thefailMessage of a token.
|
Instance Variable Details |
---|
callbackAn optional callable which, if not None, will be called whenever an instance matches successfully. It may take one, two, or three parameters, depending on its needs. If one, it will be passed whatever data the token matched (i.e. whatever it would normally have returned upon being called). If two, it will be passed theZestyParser instance and the data. If
three, it will be passed the parser, the data, and the what the parser's
cursor was when this token started matching. Callbacks may raise NotMatched or ParseError with the usual behaviour. They
should also return a value, which will be returned to the calling ZestyParser instance.
|
descThe generic "description" variable which stores the "essence" of any given instance. Subclasses use this as needed. |
toAn 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). Its main purpose is to allow you to concisely do things likeToken('[0-9]+', group=0, to=int)
-- the builtin callable int will be passed the text matched
by the regex, so the token will ultimately return an integer instead of a
string or a regex match object. You can also use this property with AHT
types, for more complex multi-stage parsing. See the n3.py
and n3rdflib.py examples for a demonstration of this. (In
previous versions, this was passed to the initializer as as ,
but this is deprecated because as will become a reserved
word in Python 2.6. Change your code to use {to}.)
|
Class Variable Details |
---|
callbackArgCount
|
failMessage
|
_call_orig
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Mar 22 02:13:39 2007 | http://epydoc.sf.net |