pyparsing_regex package¶
pyparsing_regex is a reimplementation of the pyparsing interface, building upon regular expressions.
It is intended to be a replacement for pyparsing where no recursion is needed, in order to speed up parsing significantly (factor 100). The outputs are roughly similar
The index-interface of the parse result is analog to the of pyparsing, i.e. with string-keys “example-key” you can access
all entries where setResultName("example-key") was called.
Alternatively you can access elements with integer-key, in a list like way.
Important to know, the Group class creates a nesting within this listing interface.
In addition to pyparsing, pyparsing_regex has a GroupLiftKeys class which works like Group, only that all keys
are also available at the upper level (encompassing everything which belongs to that key further down). In a normal
Group, the nested keys would be hided from the upper layer, which might not be what is wanted.
The returned object is a schlichtanders.myobjects.Structure which is a general powerful datastructure imitating
pyparsings ParseResult in a general way.
For further documentation, see also http://pyparsing.wikispaces.com/
This lives on github https://github.com/schlichtanders/pyparsing_regex
-
class
pyparsing_regex.Word(initChars, bodyChars=None, min=1, max=0, exact=0, excludeChars=None)[source]¶ Bases:
pyparsing_regex._core.ParserElement
-
class
pyparsing_regex.CharsNotIn(notChars, min=1, max=0, exact=0)[source]¶ Bases:
pyparsing_regex._interface.Word
-
class
pyparsing_regex.SkipTo(expr, include_=False)[source]¶ Bases:
pyparsing_regex._core.ParserElement
-
pyparsing_regex.MatchFirst(iterable)[source]¶ __dict__ of first element will be passed through MatchFirst result
-
pyparsing_regex.setResultsNameInPlace(expr, name, listAllMatches=False)[source]¶ adds resultsname in place, no copy as with method
Parameters: - expr – parser to set resultsname
- name – resultsname
- listAllMatches – whether strings matches should all be listed, or only last match should be kept
-
class
pyparsing_regex.ParserElement(pattern, silent=False)[source]¶ Bases:
pyparsing_regex._core.ParserElementTypewe can immitate arbitrarily complex formula directly by a single regex-string the output gets restructured (in linear time) to fulfil ParserElement/Structure interface
not implemented: whitespaces support
-
EMPTY= None¶
-