Skip to content

Commit 07a2e81

Browse files
committed
Add docstring and comments.
1 parent 4235eb8 commit 07a2e81

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sqlparse/keywords.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212

1313
def is_keyword(value):
14+
"""Checks for a keyword.
15+
16+
If the given value is in one of the KEYWORDS_* dictionary
17+
it's considered a keyword. Otherwise tokens.Name is returned.
18+
"""
1419
val = value.upper()
1520
return (KEYWORDS_COMMON.get(val)
1621
or KEYWORDS_ORACLE.get(val)
@@ -57,7 +62,7 @@ def is_keyword(value):
5762
# see issue #39
5863
# Spaces around period `schema . name` are valid identifier
5964
# TODO: Spaces before period not implemented
60-
(r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name' .
65+
(r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name'.
6166
# FIXME(atronah): never match,
6267
# because `re.match` doesn't work with look-behind regexp feature
6368
(r'(?<=\.)[A-ZÀ-Ü]\w*', tokens.Name), # .'Name'
@@ -92,6 +97,8 @@ def is_keyword(value):
9297
(r"(AT|WITH')\s+TIME\s+ZONE\s+'[^']+'", tokens.Keyword.TZCast),
9398
(r'(NOT\s+)?(LIKE|ILIKE|RLIKE)\b', tokens.Operator.Comparison),
9499
(r'(NOT\s+)?(REGEXP)\b', tokens.Operator.Comparison),
100+
# Check for keywords, also returns tokens.Name if regex matches
101+
# but the match isn't a keyword.
95102
(r'[0-9_A-ZÀ-Ü][_$#\w]*', is_keyword),
96103
(r'[;:()\[\],\.]', tokens.Punctuation),
97104
(r'[<>=~!]+', tokens.Operator.Comparison),

0 commit comments

Comments
 (0)