| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
ParserElement --+
|
ParseExpression
Abstract subclass of ParserElement, for combining and post-processing parsed tokens.
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
| Static Methods | |
|
Inherited from |
| Class Variables | |
|
Inherited from |
| Properties | |
|
Inherited from |
| Method Details |
x.__init__(...) initializes x; see help(type(x)) for signature
|
Extends
|
Define expression to be ignored (e.g., comments) while doing pattern matching; may be called repeatedly, to define multiple comment or other ignorable patterns. Example:
patt = OneOrMore(Word(alphas))
patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj']
patt.ignore(cStyleComment)
patt.parseString('ablaj /* comment */ lskjd') # -> ['ablaj', 'lskjd']
|
str(x)
|
|
Define name for referencing matching tokens as a nested attribute of
the returned parse results. NOTE: this returns a *copy* of the original
You can also set results names using the abbreviated syntax,
Example:
date_str = (integer.setResultsName("year") + '/'
+ integer.setResultsName("month") + '/'
+ integer.setResultsName("day"))
# equivalent form:
date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
|
Check defined expressions for valid structure, check for infinite recursive definitions.
|
Make a copy of this Example:
integer = Word(nums).setParseAction(lambda toks: int(toks[0]))
integerK = integer.copy().addParseAction(lambda toks: toks[0]*1024) + Suppress("K")
integerM = integer.copy().addParseAction(lambda toks: toks[0]*1024*1024) + Suppress("M")
print(OneOrMore(integerK | integerM | integer).parseString("5K 100 640K 256M"))
prints: [5120, 100, 655360, 268435456] Equivalent form of
integerM = integer().addParseAction(lambda toks: toks[0]*1024*1024) + Suppress("M")
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Aug 14 16:58:53 2016 | http://epydoc.sourceforge.net |