|
11 | 11 |
|
12 | 12 |
|
13 | 13 | 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 | + """ |
14 | 19 | val = value.upper() |
15 | 20 | return (KEYWORDS_COMMON.get(val) |
16 | 21 | or KEYWORDS_ORACLE.get(val) |
@@ -57,7 +62,7 @@ def is_keyword(value): |
57 | 62 | # see issue #39 |
58 | 63 | # Spaces around period `schema . name` are valid identifier |
59 | 64 | # TODO: Spaces before period not implemented |
60 | | - (r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name' . |
| 65 | + (r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name'. |
61 | 66 | # FIXME(atronah): never match, |
62 | 67 | # because `re.match` doesn't work with look-behind regexp feature |
63 | 68 | (r'(?<=\.)[A-ZÀ-Ü]\w*', tokens.Name), # .'Name' |
@@ -92,6 +97,8 @@ def is_keyword(value): |
92 | 97 | (r"(AT|WITH')\s+TIME\s+ZONE\s+'[^']+'", tokens.Keyword.TZCast), |
93 | 98 | (r'(NOT\s+)?(LIKE|ILIKE|RLIKE)\b', tokens.Operator.Comparison), |
94 | 99 | (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. |
95 | 102 | (r'[0-9_A-ZÀ-Ü][_$#\w]*', is_keyword), |
96 | 103 | (r'[;:()\[\],\.]', tokens.Punctuation), |
97 | 104 | (r'[<>=~!]+', tokens.Operator.Comparison), |
|
0 commit comments