Home | Trees | Index | Help |
---|
Package ZestyParser :: Module Tokens :: Class AbstractToken |
|
object
--+
|
AbstractToken
CompositeToken
,
Default
,
Defer
,
EncloseHelper
,
IndentHelper
,
Lookahead
,
Negative
,
Omit
,
Raw
,
RE
,
Skip
,
TakeToken
,
TokenSequence
,
TokenSeries
,
TokenWrapper
,
_EOF
,
_Whitespace
,
IndentationLevel
Method Summary | |
---|---|
__init__(self,
desc,
callback,
to,
as,
name)
| |
Allows you to construct TokenSequence s with the + operator. | |
__copy__(self)
| |
__imod__(self,
val)
| |
__invert__(self)
| |
__mod__(self,
val)
| |
Allows you to construct TokenSeries with the * operator. | |
Allows you to construct CompositeToken s with the | operator. | |
__repr__(self)
| |
Allows you to construct TokenSeries with the * operator. | |
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)
| |
Allows you to construct TokenSequence s with the - operator,
automatically padded with Whitespace . | |
Overloading for setting the failMessage of a token. | |
_make_callbackrun(self,
func,
callback)
| |
_make_failcheck(self,
func)
| |
_make_torun(self,
func)
| |
_poke(self)
| |
_replace(self,
vals,
kwvals)
| |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle |
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 | |
---|---|
NoneType |
failMessage = None |
NoneType |
name = None |
Method Details |
---|
__add__(self,
other)
Allows you to construct |
__mul__(self, val)Allows you to constructTokenSeries with the * operator. Operand
can be:
|
__or__(self,
other)
Allows you to construct |
__rmul__(self, val)Allows you to constructTokenSeries with the * operator. Operand
can be:
|
__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 | .
|
__sub__(self,
other)
|
__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 |
---|
failMessage
|
name
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Apr 26 01:32:22 2007 | http://epydoc.sf.net |