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

Pure-python implementation of ObjectGenerator classes

 
Classes
       
object
CallableParser
ElementToken
CILiteral
EOF
Group
FirstOfGroup
SequentialGroup
LibraryElement
Literal
Name
Range
ErrorOnFail
Match
Updater
UpdateErrorOnFail
UpdateErrorOnFailLookahead(UpdateLookahead, UpdateErrorOnFail)
UpdateLookahead
UpdateStandard
Exception(BaseException)
NoMatch
EOFReached
UpdateLookahead(Updater)
UpdateErrorOnFailLookahead(UpdateLookahead, UpdateErrorOnFail)

 
class CILiteral(ElementToken)
    
Method resolution order:
CILiteral
ElementToken
object

Methods defined here:
__init__(self, value, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
parse(self, buffer, start, stop, current)

Methods inherited from ElementToken:
__repr__(self)
final_method(self, generator=None, noReport=False)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class CallableParser(object)
     Methods defined here:
__call__(self, buffer, start=0, stop=None, current=None, *args, **named)
__init__(self, grammar)

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

 
class EOF(ElementToken)
    
Method resolution order:
EOF
ElementToken
object

Methods defined here:
parse(self, buffer, start, stop, current)

Methods inherited from ElementToken:
__init__(self, value=None, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
Initialize the object with named attributes
 
This method simply takes the named attributes and
updates the object's dictionary with them
__repr__(self)
final_method(self, generator=None, noReport=False)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class EOFReached(NoMatch)
    Raised when no match because EOF reached
 
 
Method resolution order:
EOFReached
NoMatch
Exception
BaseException
object

Data descriptors inherited from NoMatch:
__weakref__
list of weak references to the object (if defined)

Methods inherited from Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from BaseException:
__dict__
args
message

 
class ElementToken(object)
    Base class for ElementTokens, provides fallback implementations for flag-parsing based on core "parse" method
 
  Methods defined here:
__init__(self, value=None, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
Initialize the object with named attributes
 
This method simply takes the named attributes and
updates the object's dictionary with them
__repr__(self)
final_method(self, generator=None, noReport=False)
parse(self, buffer, start, stop, current)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class ErrorOnFail(object)
    When called as a matching function, raises a SyntaxError
 
Attributes:
    expected -- list of strings describing expected productions
    production -- string name of the production that's failing to parse
    message -- overrides default message generation if non-null
 
 
(something,something)+!
(something,something)!
(something,something)+!"Unable to parse somethings in my production"
(something,something)!"Unable to parse somethings in my production"
 
if string -> give an explicit message (with optional % values)
else -> use a default string
 
  Methods defined here:
__call__(self, buffer, start, stop, current)
Method called if our attached production fails
__init__(self, production='', message='', expected='')
copy(self)

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

Data and other attributes defined here:
expected = ''
message = ''
production = ''

 
class FirstOfGroup(Group)
    
Method resolution order:
FirstOfGroup
Group
ElementToken
object

Methods defined here:
parse(self, buffer, start, stop, current, where=0)

Methods inherited from Group:
__init__(self, children, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
final_method(self, generator=None, noReport=False)

Methods inherited from ElementToken:
__repr__(self)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class Group(ElementToken)
    
Method resolution order:
Group
ElementToken
object

Methods defined here:
__init__(self, children, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
final_method(self, generator=None, noReport=False)

Methods inherited from ElementToken:
__repr__(self)
parse(self, buffer, start, stop, current)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class LibraryElement(ElementToken)
    Holder for a prebuilt item with it's own generator
 
 
Method resolution order:
LibraryElement
ElementToken
object

Methods defined here:
__init__(self, production, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None, methodSource=None)
parse(self, buffer, start, stop, current)
Implement expanded references for library elements

Data descriptors defined here:
target

Methods inherited from ElementToken:
__repr__(self)
final_method(self, generator=None, noReport=False)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class Literal(ElementToken)
    
Method resolution order:
Literal
ElementToken
object

Methods defined here:
__init__(self, value, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
parse(self, buffer, start, stop, current)

Methods inherited from ElementToken:
__repr__(self)
final_method(self, generator=None, noReport=False)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class Match(object)
    A token generated during a parse
 
token -- the token which matched 
tag -- the tag (token.value) which matched 
start -- the index at which the match started 
children -- the children (if any) of the match
 
  Methods defined here:
__cmp__(self, other)
__eq__(self, other)
__getitem__(self, index)
__init__(self, token, start=None, stop=None, current=None, children=None)
__len__(self)
__repr__(self)

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

 
class Name(ElementToken)
    Reference to another rule in the grammar
 
The Name element token allows you to reference another
production within the grammar.  There are three major
sub-categories of reference depending on both the Name
element token and the referenced table's values.
 
if the Name token's report attribute is false,
or the target table's report attribute is false,
or the Name token negative attribute is true,
    the Name reference will report nothing in the result tree
 
if the target's expand attribute is true, however,
    the Name reference will report the children
    of the target production without reporting the
    target production's results (SubTable match)
 
finally:
    if the target is not expanded and the Name token
    should report something, the generator object is
    asked to supply the tag object and flags for
    processing the results of the target.  See the
    generator.MethodSource documentation for details.
 
Notes:
    expanded and un-reported productions won't get any
    methodsource methods called when
    they are finished, that's just how I decided to
    do it, not sure if there's some case where you'd
    want it.  As a result, it's possible to have a
    method getting called for one instance (where a
    name ref is reporting) and not for another (where
    the name ref isn't reporting).
 
 
Method resolution order:
Name
ElementToken
object

Methods defined here:
parse(self, buffer, start, stop, current)
Implement wrapping of results for name references

Data descriptors defined here:
target

Data and other attributes defined here:
expand_child = False
report_child = True

Methods inherited from ElementToken:
__init__(self, value=None, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
Initialize the object with named attributes
 
This method simply takes the named attributes and
updates the object's dictionary with them
__repr__(self)
final_method(self, generator=None, noReport=False)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class NoMatch(Exception)
    Raised when no match is found
 
 
Method resolution order:
NoMatch
Exception
BaseException
object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from BaseException:
__dict__
args
message

 
class Range(ElementToken)
    Match a range (set of ranges) of characters
 
 
Method resolution order:
Range
ElementToken
object

Methods defined here:
parse(self, buffer, start, stop, current)
parse_negative(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_repeating(self, buffer, start, stop, current)

Methods inherited from ElementToken:
__init__(self, value=None, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
Initialize the object with named attributes
 
This method simply takes the named attributes and
updates the object's dictionary with them
__repr__(self)
final_method(self, generator=None, noReport=False)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class SequentialGroup(Group)
    Parse a sequence of elements as a single token (with back-tracking)
 
 
Method resolution order:
SequentialGroup
Group
ElementToken
object

Methods defined here:
parse(self, buffer, start, stop, current)

Methods inherited from Group:
__init__(self, children, negative=False, optional=False, repeating=False, report=True, errorOnFail=None, expanded=False, lookahead=False, generator=None)
final_method(self, generator=None, noReport=False)

Methods inherited from ElementToken:
__repr__(self)
parse_negative(self, buffer, start, stop, current)
parse_negative_optional(self, buffer, start, stop, current)
parse_negative_repeating(self, buffer, start, stop, current)
parse_negative_repeating_optional(self, buffer, start, stop, current)
parse_optional(self, buffer, start, stop, current)
By default, run the base parse and consider failure success
parse_repeating(self, buffer, start, stop, current)
By default, run base parse until it fails, push all tokens to the stack
parse_repeating_optional(self, buffer, start, stop, current)
to_parser(self, generator=None, noReport=False)

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

 
class UpdateErrorOnFail(Updater)
    
Method resolution order:
UpdateErrorOnFail
Updater
object

Methods defined here:
__call__(self, buffer, start, stop, current)
__init__(self, final_parser, token, errorOnFail)

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

 
class UpdateErrorOnFailLookahead(UpdateLookahead, UpdateErrorOnFail)
    Combines both types of update customization
 
 
Method resolution order:
UpdateErrorOnFailLookahead
UpdateLookahead
UpdateErrorOnFail
Updater
object

Methods defined here:
__call__(self, buffer, start, stop, current)

Methods inherited from UpdateErrorOnFail:
__init__(self, final_parser, token, errorOnFail)

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

 
class UpdateLookahead(Updater)
    
Method resolution order:
UpdateLookahead
Updater
object

Methods defined here:
__call__(self, buffer, start, stop, current)

Methods inherited from Updater:
__init__(self, final_parser, token)

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

 
class UpdateStandard(Updater)
    
Method resolution order:
UpdateStandard
Updater
object

Methods defined here:
__call__(self, buffer, start, stop, current)

Methods inherited from Updater:
__init__(self, final_parser, token)

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

 
class Updater(object)
    Base class for the various updater algorithms
 
  Methods defined here:
__call__(self, buffer, start, stop, current)
__init__(self, final_parser, token)

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

 
Data
        EMPTY = None
__file__ = '/usr/src/tmp/python3-module-simpleparse-buildroo...hon3/site-packages/simpleparse/objectgenerator.py'
__name__ = 'simpleparse.objectgenerator'
__package__ = 'simpleparse'
err = ImportError('No module named pypy',)
pypy = None