Home | Trees | Indices | Help |
---|
|
object --+ | ParserElement --+ | Token --+ | Keyword
Token to exactly match a specified string as a keyword, that is, it must be immediately followed by a non-keyword character. Compare with :class:`Literal`:
Accepts two optional constructor arguments in addition to the keyword string:
Example:
Keyword("start").parseString("start") # -> ['start'] Keyword("start").parseString("starting") # -> Exception
For case-insensitive matching, use :class:`CaselessKeyword`.
|
|||
Inherited from |
|
|||
|
|||
Inherited from |
|
|||
DEFAULT_KEYWORD_CHARS =
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
x.__init__(...) initializes x; see help(type(x)) for signature
|
|
Make a copy of this :class:`ParserElement`. Useful for defining different parse actions for the same parsing pattern, using copies of the original parse element. 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 ``expr.copy()`` is just ``expr()``: integerM = integer().addParseAction(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")
|
|
DEFAULT_KEYWORD_CHARS
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Dec 25 07:03:29 2019 | http://epydoc.sourceforge.net |