A scanner holds a buffer for lookahead parsing and has the
ability to scan for special tokens and indicators in that
buffer.
Methods
|
|
|
|
__getitem__
|
__getitem__ ( self, index )
|
|
__init__
|
__init__ ( self, data=None )
|
|
__len__
|
__len__ ( self )
|
|
__nonzero__
|
__nonzero__ ( self )
|
|
check
|
check (
self,
i,
archetype=None,
)
Scan for the next single or triple quote, with the specified
archetype (if the archetype is present, only trigger on those types
of quotes. Return the found quote or None.
Exceptions
|
|
TransientParseError, "need to scan for rest of quote"
|
|
|
chop
|
chop (
self,
count=None,
slop=False,
)
Chop the first count + slop characters off the front, and return
the first count. If count is not specified, then return
everything.
|
|
complex
|
complex (
self,
enter,
exit,
start=0,
end=None,
skip=None,
)
Scan from i for an ending sequence, respecting entries and
exits.
Exceptions
|
|
TransientParseError, "expecting end of complex expression"
|
|
|
feed
|
feed ( self, data )
Feed some more data to the scanner.
|
|
find
|
find (
self,
sub,
start=0,
end=None,
)
Find the next occurrence of the character, or return -1.
|
|
keyword
|
keyword (
self,
word,
start=0,
end=None,
mandatory=False,
)
Exceptions
|
|
ParseError, "missing keyword %s" % word
TransientParseError, "missing keyword %s" % word
|
|
|
next
|
next (
self,
target,
start=0,
end=None,
mandatory=False,
)
Scan from i to j for the next occurrence of one of the characters
in the target string; optionally, make the scan mandatory.
Exceptions
|
|
ParseError, "expecting %s, not found" % target
TransientParseError, "expecting ending character"
|
|
|
phrase
|
phrase ( self, start=0 )
Scan from i for a phrase (e.g., word , f(a, b, c) , 'a[i]', or
combinations like 'x[i](a)'.
|
|
push
|
push ( self, data )
Push data back; the reverse of chop.
|
|
read
|
read (
self,
i=0,
count=1,
)
Read count chars starting from i; raise a transient error if
there aren't enough characters remaining.
Exceptions
|
|
TransientParseError, "need more data to read"
|
|
|
rest
|
rest ( self )
Get the remainder of the buffer.
|
|
set
|
set ( self, data )
Start the scanner digesting a new batch of data; start the pointer
over from scratch.
|
|
simple
|
simple ( self, start=0 )
Scan from i for a simple expression, which consists of one
more phrases separated by dots.
|
|
word
|
word ( self, start=0 )
Scan from i for a simple word.
Exceptions
|
|
TransientParseError, "expecting end of word"
|
|
|