Class: Scanner

Table of Contents

Class: Scanner | em.py
--- | ---
A scanner holds a buffer for lookahead parsing and has the ability to scan for special symbols and indicators in that buffer.
Methods |
--- | ---
__getitem__ __getslice__ __init__ __len__ __nonzero__ acquire advance check chop | complex feed find last nested next one phrase quote | read release rest retreat set simple sync unsync word
| __getitem__
    __getitem__ ( self,  index )
| __getslice__
    __getslice__ (
            self,
            start,
            stop,
            )
| __init__
    __init__ (
            self,
            prefix,
            data='',
            )
| __len__
    __len__ ( self )
| __nonzero__
    __nonzero__ ( self )
| acquire
    acquire ( self )
Lock the scanner so it doesn't destroy data on sync.
| advance
    advance ( self,  count=1 )
Advance the pointer count characters.
| check
    check (
            self,
            i,
            archetype=None,
            )
Scan for the next single or triple quote, with the specified archetype. Return the found quote or None.
Exceptions |
--- | ---
TransientParseError, "need to scan for rest of quote"
| chop
    chop (
            self,
            count=None,
            slop=0,
            )
Chop the first count + slop characters off the front, and return the first count. If count is not specified, then return everything.
Exceptions |
--- | ---
TransientParseError, "not enough data to read"
| complex
    complex (
            self,
            enter,
            exit,
            start=0,
            end=None,
            skip=None,
            )
Scan from i for an ending sequence, respecting quotes, 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.
| last
    last (
            self,
            char,
            start=0,
            end=None,
            )
Find the first character that is not the specified character.
Exceptions |
--- | ---
TransientParseError, "expecting other than %s" % char
| nested
    nested (
            self,
            enter,
            exit,
            start=0,
            end=None,
            )
Scan from i for an ending sequence, respecting entries and exits only.
Exceptions |
--- | ---
TransientParseError, "expecting end of complex expression"
| next
    next (
            self,
            target,
            start=0,
            end=None,
            mandatory=False,
            )
Scan 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"
| one
    one ( self )
Parse and return one token, or None if the scanner is empty.
Exceptions |
--- | ---
ParseError, "unknown markup: %s%s" %( self.prefix, first )
| 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)'.
Exceptions |
--- | ---
ParseError, "curly braces can't open simple expressions"
| quote
    quote (
            self,
            start=0,
            end=None,
            mandatory=False,
            )
Scan for the end of the next quote.
Exceptions |
--- | ---
ParseError, "expecting end of string literal" TransientParseError, "expecting end of string literal"
| 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"
| release
    release ( self )
Unlock the scanner.
| rest
    rest ( self )
Get the remainder of the buffer.
| retreat
    retreat ( self,  count=1 )
Exceptions |
--- | ---
ParseError, "can't retreat back over synced out chars"
| 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.
| sync
    sync ( self )
Sync up the buffer with the read head.
| unsync
    unsync ( self )
Undo changes; reset the read head.
| word
    word ( self,  start=0 )
Scan from i for a simple word.
Exceptions |
--- | ---
TransientParseError, "expecting end of word"

Table of Contents

This document was automatically generated on Mon Oct 27 01:29:13 2003 by HappyDoc version 2.1