Skip to content

Commit

Permalink
Add docstring and comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
andialbrecht committed Sep 6, 2022
1 parent 4235eb8 commit 07a2e81
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sqlparse/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


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

0 comments on commit 07a2e81

Please sign in to comment.