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

Default SimpleParse EBNF grammar as a generator with productions
 
This module defines the original SimpleParse
grammar.  It uses the generator objects directly
as this is the first grammar being written.

 
Modules
       
simpleparse.baseparser
simpleparse.generator
string

 
Classes
       
BaseParser(object)
Parser
DispatchProcessor(Processor)
SPGrammarProcessor

 
class Parser(BaseParser)
    Parser which generates new parsers from EBNF grammars
 
This parser class allows you to pass in an EBNF grammar as
the initialisation parameter.  The EBNF is processed, and a
SimpleParse generator object is created as self.generator.
 
Unlike most Parsers, this object is intended to be re-created
for each bit of data it parses (i.e. each EBNF), so it warps
the standard API a lot.
 
 
Method resolution order:
Parser
BaseParser
object

Methods defined here:
__init__(self, ebnf, prebuilts=(), methodSource=None, definitionSources=())
Create a new generator based on the EBNF in simpleparse format
buildParser(self, name=None, processor=None)
Build the tag-table for parsing the EBNF for this parser

Methods inherited from BaseParser:
buildProcessor(self)
Build default processor object for this parser class
 
The default implementation returns None.  The processor
can either implement the "method source" API (just provides
information about Callouts and the like), or the processor
API and the method-source API.  The processor API merely
requires that the object be callable, and have the signature:
 
    object( (success, children, nextPosition), buffer)
 
(Note: your object can treat the first item as a single tuple
if it likes).
 
See: simpleparse.processor module for details.
parse(self, data, production=None, processor=None, start=0, stop=None)
Parse data with production "production" of this parser
 
data -- data to be parsed, a Python string, for now
production -- optional string specifying a non-default production to use
    for parsing data
processor -- optional pointer to a Processor or MethodSource object for
    use in determining reporting format and/or post-processing the results
    of the parsing pass.  Can be None if neither is desired (default)
start -- starting index for the parsing, default 0
stop -- stoping index for the parsing, default len(data)
resetBeforeParse(self)
Called just before the parser's parse method starts working,
 
Allows you to set up special-purpose structures, such as stacks
or local storage values.  There is no base implementation.  The
base implementation does nothing.

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

 
class SPGrammarProcessor(DispatchProcessor)
    Processing object for post-processing an EBNF into a new generator
 
 
Method resolution order:
SPGrammarProcessor
DispatchProcessor
Processor
MethodSource
object

Methods defined here:
CHAR = CHARNODBLQUOTE(self, tup, buffer)
CHARBRACE(self, tup, buffer)
CHARDASH(self, tup, buffer)
CHARNOBRACE(self, match, buffer)
CHARNODBLQUOTE(self, tup, buffer)
CHARNOSNGLQUOTE = CHARNODBLQUOTE(self, tup, buffer)
CHARRANGE(self, match, buffer)
Create a string from first to second item
ESCAPEDCHAR(self, match, buffer)
HEXESCAPEDCHAR(self, tup, buffer)
OCTALESCAPEDCHAR(self, tup, buffer)
SPECIALESCAPEDCHAR(self, tup, buffer)
UNICODEESCAPEDCHAR_16(self, match, buffer)
Only available in unicode-aware Python versions
UNICODEESCAPEDCHAR_32 = UNICODEESCAPEDCHAR_16(self, match, buffer)
__init__(self, prebuilts=(), definitionSources=())
Create a new generator based on the EBNF in simpleparse format
declaration(self, match, buffer)
Base declaration from the grammar, a "production" or "rule"
element_token(self, match, buffer)
get the children, then configure
error_on_fail(self, match, buffer)
If present, we are going to make the current object an errorOnFail type,
 
If there's a string literal child, then we use it to create the
"message" attribute of the errorOnFail object.
fo_group(self, match, buffer)
Process a first-of-group into a FirstOf element token
literal(self, match, buffer)
Turn a literal result into a literal generator
lookahead_indicator(self, tup, buffer)
If present, the lookahead indictor just says "yes", so just return 1
name(self, tup, buffer)
negpos_indicator(self, tup, buffer)
return whether indicates negative
occurence_indicator(self, tup, buffer)
Return optional, repeating as a tuple of true/false values
range(self, match, buffer)
seq_group(self, match, buffer)
Process a sequential-group into a SequentialGroup element token

Data and other attributes defined here:
negposIndicatorMap = {'+': 0, '-': 1}
occurenceIndicatorMap = {'*': (1, 1), '+': (0, 1), '?': (1, 0)}
specialescapedmap = {'"': '"', "'": "'", r'\': r'\', 'a': '\x07', 'b': '\x08', 'f': '\x0c', 'n': '\n', 'r': '\r', 't': '\t', 'v': '\x0b'}

Methods inherited from DispatchProcessor:
__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)

 
Data
        EMPTY = None
HAVE_UNICODE = 1
SPGenerator = <simpleparse.generator.Generator object>
__file__ = '/usr/src/tmp/python3-module-simpleparse-buildroo...3/site-packages/simpleparse/simpleparsegrammar.py'
__name__ = 'simpleparse.simpleparsegrammar'
__package__ = 'simpleparse'
_seq_children = FirstOfGroup(value=[Name(value='error_on_fail',r...,repeating=False,expanded=False,lookahead=False )
characterrange = Name(value='range',report=True,negative=False,op...,repeating=False,expanded=False,lookahead=False )
declaration = 'declarationset := declaration+\ndeclaration...,[0-9a-fA-F],[0-9a-fA-F],[0-9a-fA-F],[0-9a-fA-F]\n'
element_token = Name(value='element_token',report=True,negative=...,repeating=False,expanded=False,lookahead=False )
err = ImportError('No module named pypy',)
group = Name(value='group',report=True,negative=False,op...,repeating=False,expanded=False,lookahead=False )
literal = Name(value='literal',report=True,negative=False,...,repeating=False,expanded=False,lookahead=False )
name = Name(value='name',report=True,negative=False,opt...,repeating=False,expanded=False,lookahead=False )
pypy = None
whitespace = Name(value='ts',report=0,negative=False,optional...,repeating=False,expanded=False,lookahead=False )