summaryrefslogtreecommitdiff
path: root/pyparsing/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r--pyparsing/core.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py
index fecebb4..c466dbc 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -2449,8 +2449,8 @@ ParserElement._literalStringClass = Literal
class Keyword(Token):
"""
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`:
+ it must be immediately preceded and followed by whitespace or
+ non-keyword characters. Compare with :class:`Literal`:
- ``Literal("if")`` will match the leading ``'if'`` in
``'ifAndOnlyIf'``.
@@ -2838,6 +2838,8 @@ class Word(Token):
self.errmsg = "Expected " + self.name
self.mayIndexError = False
self.asKeyword = asKeyword
+ if self.asKeyword:
+ self.errmsg += " as a keyword"
# see if we can make a regex for this Word
if " " not in (self.initChars | self.bodyChars):