simpleparse.dispatchprocessor
index
/usr/src/tmp/python3-module-simpleparse-buildroot/usr/lib/python3/site-packages/simpleparse/dispatchprocessor.py

Dispatch-processor API
 
This is a post-processing processor API based on dispatching
each element of a result tree in a top-down recursive call
structure.  It is the API used by the SimpleParseGrammar Parser,
and likely will be the default processor for SimpleParse.

 
Classes
       
Processor(MethodSource)
DispatchProcessor

 
class DispatchProcessor(Processor)
    Dispatch results-tree in a top-down recursive pattern with
attribute lookup to determine production -> method correspondence.
 
To use the class, subclass it, then define methods for
processing each production.  The methods should take this form:
    def production_name( self, (tag, left, right, children), buffer):
        pass
Where children may be either a list, or None, and buffer is the
entire buffer being parsed.
 
 
Method resolution order:
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
__call__(self, value, buffer)
Process the results of the parsing run over buffer
 
Value can either be: (success, tags, next) for a top-level
production, or (tag, left, right, children) for a non-top
production.

Methods inherited from Processor:
__repr__(self)
Return a representation of the class

Data descriptors inherited from MethodSource:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
dispatch(source, tag, buffer)
Dispatch on source for tag with buffer
 
Find the attribute or key tag[0] of source,
then call it with (tag, buffer)
dispatchList(source, taglist, buffer)
Dispatch on source for each tag in taglist with buffer
getString(match, buffer)
Return the string value of the tag passed
lines(start=None, end=None, buffer=None)
Return line number in file at character index (string.count version)
multiMap(taglist, source=None, buffer=None)
Convert a taglist to a mapping from tag-object:[list-of-tags]
 
For instance, if you have items of 3 different types, in any order,
you can retrieve them all sorted by type with multimap( childlist)
then access them by tagobject key.
singleMap(taglist, source=None, buffer=None)
Convert a taglist to a mapping from tag-object:tag, overwritting early with late tags

 
Data
        __file__ = '/usr/src/tmp/python3-module-simpleparse-buildroo...n3/site-packages/simpleparse/dispatchprocessor.py'
__name__ = 'simpleparse.dispatchprocessor'
__package__ = 'simpleparse'