class documentation

class Parser(object): (source)

View In Hierarchy

Parser class that matches multiple rules at once. It will compile the patterns of various rules into a single regex and based on the match call the correct rules for processing.
Method __call__ No summary
Method __init__ No summary
Method __or__ Allow new parsers to be constructed by combining parser objects with the "|" operator.
Method backup_parser_offset Undocumented
Instance Variable process_unmatched function (or object) to process un-matched text, or None. The function should take a Builder object as first argument, followed by one or more parameters for matched groups in the regular expression.
Instance Variable rules list with Rule objects, can be modified until the parser is used for the first time for parsing (the attribute becomes a tuple afterwards)
Static Method _raise_exception Undocumented
Method _process_unmatched Undocumented
Instance Variable _backup_iter Undocumented
Instance Variable _re Undocumented
def __call__(self, builder, text): (source)
Each parser object is callable so it can be used as a processing function in any other parser object. This method parses the given text and calls the appropriate methods of the Builder object to construct the parse results.
Parameters
buildera Builder object
textto be parsed text as string
def __init__(self, *rules): (source)
Constructor
Parameters
*ruleslist of rules to match (each should derive from SimpleReParser, so be either a single rule, or a compound rule.)
def __or__(self, other): (source)
Allow new parsers to be constructed by combining parser objects with the "|" operator.
def backup_parser_offset(self, i): (source)

Undocumented

process_unmatched = (source)
function (or object) to process un-matched text, or None. The function should take a Builder object as first argument, followed by one or more parameters for matched groups in the regular expression.
rules = (source)
list with Rule objects, can be modified until the parser is used for the first time for parsing (the attribute becomes a tuple afterwards)
@staticmethod
def _raise_exception(error, text, start, end, builder, rule=None): (source)

Undocumented

def _process_unmatched(self, builder, text): (source)

Undocumented

_backup_iter: int = (source)

Undocumented

Undocumented