| 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
Literal:
Literal("if") will match the leading
'if' in 'ifAndOnlyIf'.
Keyword("if") will not; it will only match the
leading 'if' in 'if x=1', or
'if(y==2)'
Accepts two optional constructor arguments in addition to the keyword string:
identChars is a string of characters that would be valid
identifier characters, defaulting to all alphanumerics +
"_" and "$"
caseless allows case-insensitive matching, default is
False.
Example:
Keyword("start").parseString("start") # -> ['start']
Keyword("start").parseString("starting") # -> Exception
For case-insensitive matching, use CaselessKeyword.
| Static Methods | |||
|
|||
|
Inherited from |
|||
| Class Variables | |
DEFAULT_KEYWORD_CHARS =
|
|
|
Inherited from |
|
| Properties | |
|
Inherited from |
| Method Details |
x.__init__(...) initializes x; see help(type(x)) for signature
|
|
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")
|
| Class Variable Details |
DEFAULT_KEYWORD_CHARS
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu Oct 06 20:32:29 2016 | http://epydoc.sourceforge.net |