codekingpro/portable-devtools
114k
1#2# Copyright (C) 2009-2020 the sqlparse authors and contributors3# <see AUTHORS file>4#5# This module is part of python-sqlparse and is released under6# the BSD License: https://opensource.org/licenses/BSD-3-Clause7 8from sqlparse import tokens9 10# object() only supports "is" and is useful as a marker11# use this marker to specify that the given regex in SQL_REGEX12# shall be processed further through a lookup in the KEYWORDS dictionaries13PROCESS_AS_KEYWORD = object()14 15 16SQL_REGEX = [17 (r'(--|# )\+.*?(\r\n|\r|\n|$)', tokens.Comment.Single.Hint),18 (r'/\*\+[\s\S]*?\*/', tokens.Comment.Multiline.Hint),19 20 (r'(--|# ).*?(\r\n|\r|\n|$)', tokens.Comment.Single),21 (r'/\*[\s\S]*?\*/', tokens.Comment.Multiline),22 23 (r'(\r\n|\r|\n)', tokens.Newline),24 (r'\s+?', tokens.Whitespace),25 26 (r':=', tokens.Assignment),27 (r'::', tokens.Punctuation),28 29 (r'\*', tokens.Wildcard),30 31 (r"`(``|[^`])*`", tokens.Name),32 (r"´(´´|[^´])*´", tokens.Name),33 (r'((?<![\w\"\$])\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal),34 35 (r'\?', tokens.Name.Placeholder),36 (r'%(\(\w+\))?s', tokens.Name.Placeholder),37 (r'(?<!\w)[$:?]\w+', tokens.Name.Placeholder),38 39 (r'\\\w+', tokens.Command),40 41 # FIXME(andi): VALUES shouldn't be listed here42 # see https://github.com/andialbrecht/sqlparse/pull/6443 # AS and IN are special, it may be followed by a parenthesis, but44 # are never functions, see issue183 and issue50745 (r'(CASE|IN|VALUES|USING|FROM|AS)\b', tokens.Keyword),46 47 (r'(@|##|#)[A-ZÀ-Ü]\w+', tokens.Name),48 49 # see issue #3950 # Spaces around period `schema . name` are valid identifier51 # TODO: Spaces before period not implemented52 (r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name'.53 # FIXME(atronah): never match,54 # because `re.match` doesn't work with look-behind regexp feature55 (r'(?<=\.)[A-ZÀ-Ü]\w*', tokens.Name), # .'Name'56 (r'[A-ZÀ-Ü]\w*(?=\()', tokens.Name), # side effect: change kw to func57 (r'-?0x[\dA-F]+', tokens.Number.Hexadecimal),58 (r'-?\d+(\.\d+)?E-?\d+', tokens.Number.Float),59 (r'(?![_A-ZÀ-Ü])-?(\d+(\.\d*)|\.\d+)(?![_A-ZÀ-Ü])',60 tokens.Number.Float),61 (r'(?![_A-ZÀ-Ü])-?\d+(?![_A-ZÀ-Ü])', tokens.Number.Integer),62 (r"'(''|\\'|[^'])*'", tokens.String.Single),63 # not a real string literal in ANSI SQL:64 (r'"(""|\\"|[^"])*"', tokens.String.Symbol),65 (r'(""|".*?[^\\]")', tokens.String.Symbol),66 # sqlite names can be escaped with [square brackets]. left bracket67 # cannot be preceded by word character or a right bracket --68 # otherwise it's probably an array index69 (r'(?<![\w\])])(\[[^\]\[]+\])', tokens.Name),70 (r'((LEFT\s+|RIGHT\s+|FULL\s+)?(INNER\s+|OUTER\s+|STRAIGHT\s+)?'71 r'|(CROSS\s+|NATURAL\s+)?)?JOIN\b', tokens.Keyword),72 (r'END(\s+IF|\s+LOOP|\s+WHILE)?\b', tokens.Keyword),73 (r'NOT\s+NULL\b', tokens.Keyword),74 (r'NULLS\s+(FIRST|LAST)\b', tokens.Keyword),75 (r'UNION\s+ALL\b', tokens.Keyword),76 (r'CREATE(\s+OR\s+REPLACE)?\b', tokens.Keyword.DDL),77 (r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin),78 (r'GROUP\s+BY\b', tokens.Keyword),79 (r'ORDER\s+BY\b', tokens.Keyword),80 (r'PRIMARY\s+KEY\b', tokens.Keyword),81 (r'HANDLER\s+FOR\b', tokens.Keyword),82 (r'GO(\s\d+)\b', tokens.Keyword),83 (r'(LATERAL\s+VIEW\s+)'84 r'(EXPLODE|INLINE|PARSE_URL_TUPLE|POSEXPLODE|STACK)\b',85 tokens.Keyword),86 (r"(AT|WITH')\s+TIME\s+ZONE\s+'[^']+'", tokens.Keyword.TZCast),87 (r'(NOT\s+)?(LIKE|ILIKE|RLIKE)\b', tokens.Operator.Comparison),88 (r'(NOT\s+)?(REGEXP)\b', tokens.Operator.Comparison),89 # Check for keywords, also returns tokens.Name if regex matches90 # but the match isn't a keyword.91 (r'\w[$#\w]*', PROCESS_AS_KEYWORD),92 (r'[;:()\[\],\.]', tokens.Punctuation),93 # JSON operators94 (r'(\->>?|#>>?|@>|<@|\?\|?|\?&|\-|#\-)', tokens.Operator),95 (r'[<>=~!]+', tokens.Operator.Comparison),96 (r'[+/@#%^&|^-]+', tokens.Operator),97]98 99KEYWORDS = {100 'ABORT': tokens.Keyword,101 'ABS': tokens.Keyword,102 'ABSOLUTE': tokens.Keyword,103 'ACCESS': tokens.Keyword,104 'ADA': tokens.Keyword,105 'ADD': tokens.Keyword,106 'ADMIN': tokens.Keyword,107 'AFTER': tokens.Keyword,108 'AGGREGATE': tokens.Keyword,109 'ALIAS': tokens.Keyword,110 'ALL': tokens.Keyword,111 'ALLOCATE': tokens.Keyword,112 'ANALYSE': tokens.Keyword,113 'ANALYZE': tokens.Keyword,114 'ANY': tokens.Keyword,115 'ARRAYLEN': tokens.Keyword,116 'ARE': tokens.Keyword,117 'ASC': tokens.Keyword.Order,118 'ASENSITIVE': tokens.Keyword,119 'ASSERTION': tokens.Keyword,120 'ASSIGNMENT': tokens.Keyword,121 'ASYMMETRIC': tokens.Keyword,122 'AT': tokens.Keyword,123 'ATOMIC': tokens.Keyword,124 'AUDIT': tokens.Keyword,125 'AUTHORIZATION': tokens.Keyword,126 'AUTO_INCREMENT': tokens.Keyword,127 'AVG': tokens.Keyword,128 129 'BACKWARD': tokens.Keyword,130 'BEFORE': tokens.Keyword,131 'BEGIN': tokens.Keyword,132 'BETWEEN': tokens.Keyword,133 'BITVAR': tokens.Keyword,134 'BIT_LENGTH': tokens.Keyword,135 'BOTH': tokens.Keyword,136 'BREADTH': tokens.Keyword,137 138 # 'C': tokens.Keyword, # most likely this is an alias139 'CACHE': tokens.Keyword,140 'CALL': tokens.Keyword,141 'CALLED': tokens.Keyword,142 'CARDINALITY': tokens.Keyword,143 'CASCADE': tokens.Keyword,144 'CASCADED': tokens.Keyword,145 'CAST': tokens.Keyword,146 'CATALOG': tokens.Keyword,147 'CATALOG_NAME': tokens.Keyword,148 'CHAIN': tokens.Keyword,149 'CHARACTERISTICS': tokens.Keyword,150 'CHARACTER_LENGTH': tokens.Keyword,151 'CHARACTER_SET_CATALOG': tokens.Keyword,152 'CHARACTER_SET_NAME': tokens.Keyword,153 'CHARACTER_SET_SCHEMA': tokens.Keyword,154 'CHAR_LENGTH': tokens.Keyword,155 'CHARSET': tokens.Keyword,156 'CHECK': tokens.Keyword,157 'CHECKED': tokens.Keyword,158 'CHECKPOINT': tokens.Keyword,159 'CLASS': tokens.Keyword,160 'CLASS_ORIGIN': tokens.Keyword,161 'CLOB': tokens.Keyword,162 'CLOSE': tokens.Keyword,163 'CLUSTER': tokens.Keyword,164 'COALESCE': tokens.Keyword,165 'COBOL': tokens.Keyword,166 'COLLATE': tokens.Keyword,167 'COLLATION': tokens.Keyword,168 'COLLATION_CATALOG': tokens.Keyword,169 'COLLATION_NAME': tokens.Keyword,170 'COLLATION_SCHEMA': tokens.Keyword,171 'COLLECT': tokens.Keyword,172 'COLUMN': tokens.Keyword,173 'COLUMN_NAME': tokens.Keyword,174 'COMPRESS': tokens.Keyword,175 'COMMAND_FUNCTION': tokens.Keyword,176 'COMMAND_FUNCTION_CODE': tokens.Keyword,177 'COMMENT': tokens.Keyword,178 'COMMIT': tokens.Keyword.DML,179 'COMMITTED': tokens.Keyword,180 'COMPLETION': tokens.Keyword,181 'CONCURRENTLY': tokens.Keyword,182 'CONDITION_NUMBER': tokens.Keyword,183 'CONNECT': tokens.Keyword,184 'CONNECTION': tokens.Keyword,185 'CONNECTION_NAME': tokens.Keyword,186 'CONSTRAINT': tokens.Keyword,187 'CONSTRAINTS': tokens.Keyword,188 'CONSTRAINT_CATALOG': tokens.Keyword,189 'CONSTRAINT_NAME': tokens.Keyword,190 'CONSTRAINT_SCHEMA': tokens.Keyword,191 'CONSTRUCTOR': tokens.Keyword,192 'CONTAINS': tokens.Keyword,193 'CONTINUE': tokens.Keyword,194 'CONVERSION': tokens.Keyword,195 'CONVERT': tokens.Keyword,196 'COPY': tokens.Keyword,197 'CORRESPONDING': tokens.Keyword,198 'COUNT': tokens.Keyword,199 'CREATEDB': tokens.Keyword,200 'CREATEUSER': tokens.Keyword,201 'CROSS': tokens.Keyword,202 'CUBE': tokens.Keyword,203 'CURRENT': tokens.Keyword,204 'CURRENT_DATE': tokens.Keyword,205 'CURRENT_PATH': tokens.Keyword,206 'CURRENT_ROLE': tokens.Keyword,207 'CURRENT_TIME': tokens.Keyword,208 'CURRENT_TIMESTAMP': tokens.Keyword,209 'CURRENT_USER': tokens.Keyword,210 'CURSOR': tokens.Keyword,211 'CURSOR_NAME': tokens.Keyword,212 'CYCLE': tokens.Keyword,213 214 'DATA': tokens.Keyword,215 'DATABASE': tokens.Keyword,216 'DATETIME_INTERVAL_CODE': tokens.Keyword,217 'DATETIME_INTERVAL_PRECISION': tokens.Keyword,218 'DAY': tokens.Keyword,219 'DEALLOCATE': tokens.Keyword,220 'DECLARE': tokens.Keyword,221 'DEFAULT': tokens.Keyword,222 'DEFAULTS': tokens.Keyword,223 'DEFERRABLE': tokens.Keyword,224 'DEFERRED': tokens.Keyword,225 'DEFINED': tokens.Keyword,226 'DEFINER': tokens.Keyword,227 'DELIMITER': tokens.Keyword,228 'DELIMITERS': tokens.Keyword,229 'DEREF': tokens.Keyword,230 'DESC': tokens.Keyword.Order,231 'DESCRIBE': tokens.Keyword,232 'DESCRIPTOR': tokens.Keyword,233 'DESTROY': tokens.Keyword,234 'DESTRUCTOR': tokens.Keyword,235 'DETERMINISTIC': tokens.Keyword,236 'DIAGNOSTICS': tokens.Keyword,237 'DICTIONARY': tokens.Keyword,238 'DISABLE': tokens.Keyword,239 'DISCONNECT': tokens.Keyword,240 'DISPATCH': tokens.Keyword,241 'DIV': tokens.Operator,242 'DO': tokens.Keyword,243 'DOMAIN': tokens.Keyword,244 'DYNAMIC': tokens.Keyword,245 'DYNAMIC_FUNCTION': tokens.Keyword,246 'DYNAMIC_FUNCTION_CODE': tokens.Keyword,247 248 'EACH': tokens.Keyword,249 'ENABLE': tokens.Keyword,250 'ENCODING': tokens.Keyword,251 'ENCRYPTED': tokens.Keyword,252 'END-EXEC': tokens.Keyword,253 'ENGINE': tokens.Keyword,254 'EQUALS': tokens.Keyword,255 'ESCAPE': tokens.Keyword,256 'EVERY': tokens.Keyword,257 'EXCEPT': tokens.Keyword,258 'EXCEPTION': tokens.Keyword,259 'EXCLUDING': tokens.Keyword,260 'EXCLUSIVE': tokens.Keyword,261 'EXEC': tokens.Keyword,262 'EXECUTE': tokens.Keyword,263 'EXISTING': tokens.Keyword,264 'EXISTS': tokens.Keyword,265 'EXPLAIN': tokens.Keyword,266 'EXTERNAL': tokens.Keyword,267 'EXTRACT': tokens.Keyword,268 269 'FALSE': tokens.Keyword,270 'FETCH': tokens.Keyword,271 'FILE': tokens.Keyword,272 'FINAL': tokens.Keyword,273 'FIRST': tokens.Keyword,274 'FORCE': tokens.Keyword,275 'FOREACH': tokens.Keyword,276 'FOREIGN': tokens.Keyword,277 'FORTRAN': tokens.Keyword,278 'FORWARD': tokens.Keyword,279 'FOUND': tokens.Keyword,280 'FREE': tokens.Keyword,281 'FREEZE': tokens.Keyword,282 'FULL': tokens.Keyword,283 'FUNCTION': tokens.Keyword,284 285 # 'G': tokens.Keyword,286 'GENERAL': tokens.Keyword,287 'GENERATED': tokens.Keyword,288 'GET': tokens.Keyword,289 'GLOBAL': tokens.Keyword,290 'GO': tokens.Keyword,291 'GOTO': tokens.Keyword,292 'GRANTED': tokens.Keyword,293 'GROUPING': tokens.Keyword,294 295 'HAVING': tokens.Keyword,296 'HIERARCHY': tokens.Keyword,297 'HOLD': tokens.Keyword,298 'HOUR': tokens.Keyword,299 'HOST': tokens.Keyword,300 301 'IDENTIFIED': tokens.Keyword,302 'IDENTITY': tokens.Keyword,303 'IGNORE': tokens.Keyword,304 'ILIKE': tokens.Keyword,305 'IMMEDIATE': tokens.Keyword,306 'IMMUTABLE': tokens.Keyword,307 308 'IMPLEMENTATION': tokens.Keyword,309 'IMPLICIT': tokens.Keyword,310 'INCLUDING': tokens.Keyword,311 'INCREMENT': tokens.Keyword,312 'INDEX': tokens.Keyword,313 314 'INDICATOR': tokens.Keyword,315 'INFIX': tokens.Keyword,316 'INHERITS': tokens.Keyword,317 'INITIAL': tokens.Keyword,318 'INITIALIZE': tokens.Keyword,319 'INITIALLY': tokens.Keyword,320 'INOUT': tokens.Keyword,321 'INPUT': tokens.Keyword,322 'INSENSITIVE': tokens.Keyword,323 'INSTANTIABLE': tokens.Keyword,324 'INSTEAD': tokens.Keyword,325 'INTERSECT': tokens.Keyword,326 'INTO': tokens.Keyword,327 'INVOKER': tokens.Keyword,328 'IS': tokens.Keyword,329 'ISNULL': tokens.Keyword,330 'ISOLATION': tokens.Keyword,331 'ITERATE': tokens.Keyword,332 333 # 'K': tokens.Keyword,334 'KEY': tokens.Keyword,335 'KEY_MEMBER': tokens.Keyword,336 'KEY_TYPE': tokens.Keyword,337 338 'LANCOMPILER': tokens.Keyword,339 'LANGUAGE': tokens.Keyword,340 'LARGE': tokens.Keyword,341 'LAST': tokens.Keyword,342 'LATERAL': tokens.Keyword,343 'LEADING': tokens.Keyword,344 'LENGTH': tokens.Keyword,345 'LESS': tokens.Keyword,346 'LEVEL': tokens.Keyword,347 'LIMIT': tokens.Keyword,348 'LISTEN': tokens.Keyword,349 'LOAD': tokens.Keyword,350 'LOCAL': tokens.Keyword,351 'LOCALTIME': tokens.Keyword,352 'LOCALTIMESTAMP': tokens.Keyword,353 'LOCATION': tokens.Keyword,354 'LOCATOR': tokens.Keyword,355 'LOCK': tokens.Keyword,356 'LOWER': tokens.Keyword,357 358 # 'M': tokens.Keyword,359 'MAP': tokens.Keyword,360 'MATCH': tokens.Keyword,361 'MAXEXTENTS': tokens.Keyword,362 'MAXVALUE': tokens.Keyword,363 'MESSAGE_LENGTH': tokens.Keyword,364 'MESSAGE_OCTET_LENGTH': tokens.Keyword,365 'MESSAGE_TEXT': tokens.Keyword,366 'METHOD': tokens.Keyword,367 'MINUTE': tokens.Keyword,368 'MINUS': tokens.Keyword,369 'MINVALUE': tokens.Keyword,370 'MOD': tokens.Keyword,371 'MODE': tokens.Keyword,372 'MODIFIES': tokens.Keyword,373 'MODIFY': tokens.Keyword,374 'MONTH': tokens.Keyword,375 'MORE': tokens.Keyword,376 'MOVE': tokens.Keyword,377 'MUMPS': tokens.Keyword,378 379 'NAMES': tokens.Keyword,380 'NATIONAL': tokens.Keyword,381 'NATURAL': tokens.Keyword,382 'NCHAR': tokens.Keyword,383 'NCLOB': tokens.Keyword,384 'NEW': tokens.Keyword,385 'NEXT': tokens.Keyword,386 'NO': tokens.Keyword,387 'NOAUDIT': tokens.Keyword,388 'NOCOMPRESS': tokens.Keyword,389 'NOCREATEDB': tokens.Keyword,390 'NOCREATEUSER': tokens.Keyword,391 'NONE': tokens.Keyword,392 'NOT': tokens.Keyword,393 'NOTFOUND': tokens.Keyword,394 'NOTHING': tokens.Keyword,395 'NOTIFY': tokens.Keyword,396 'NOTNULL': tokens.Keyword,397 'NOWAIT': tokens.Keyword,398 'NULL': tokens.Keyword,399 'NULLABLE': tokens.Keyword,400 'NULLIF': tokens.Keyword,401 402 'OBJECT': tokens.Keyword,403 'OCTET_LENGTH': tokens.Keyword,404 'OF': tokens.Keyword,405 'OFF': tokens.Keyword,406 'OFFLINE': tokens.Keyword,407 'OFFSET': tokens.Keyword,408 'OIDS': tokens.Keyword,409 'OLD': tokens.Keyword,410 'ONLINE': tokens.Keyword,411 'ONLY': tokens.Keyword,412 'OPEN': tokens.Keyword,413 'OPERATION': tokens.Keyword,414 'OPERATOR': tokens.Keyword,415 'OPTION': tokens.Keyword,416 'OPTIONS': tokens.Keyword,417 'ORDINALITY': tokens.Keyword,418 'OUT': tokens.Keyword,419 'OUTPUT': tokens.Keyword,420 'OVERLAPS': tokens.Keyword,421 'OVERLAY': tokens.Keyword,422 'OVERRIDING': tokens.Keyword,423 'OWNER': tokens.Keyword,424 425 'QUARTER': tokens.Keyword,426 427 'PAD': tokens.Keyword,428 'PARAMETER': tokens.Keyword,429 'PARAMETERS': tokens.Keyword,430 'PARAMETER_MODE': tokens.Keyword,431 'PARAMETER_NAME': tokens.Keyword,432 'PARAMETER_ORDINAL_POSITION': tokens.Keyword,433 'PARAMETER_SPECIFIC_CATALOG': tokens.Keyword,434 'PARAMETER_SPECIFIC_NAME': tokens.Keyword,435 'PARAMETER_SPECIFIC_SCHEMA': tokens.Keyword,436 'PARTIAL': tokens.Keyword,437 'PASCAL': tokens.Keyword,438 'PCTFREE': tokens.Keyword,439 'PENDANT': tokens.Keyword,440 'PLACING': tokens.Keyword,441 'PLI': tokens.Keyword,442 'POSITION': tokens.Keyword,443 'POSTFIX': tokens.Keyword,444 'PRECISION': tokens.Keyword,445 'PREFIX': tokens.Keyword,446 'PREORDER': tokens.Keyword,447 'PREPARE': tokens.Keyword,448 'PRESERVE': tokens.Keyword,449 'PRIMARY': tokens.Keyword,450 'PRIOR': tokens.Keyword,451 'PRIVILEGES': tokens.Keyword,452 'PROCEDURAL': tokens.Keyword,453 'PROCEDURE': tokens.Keyword,454 'PUBLIC': tokens.Keyword,455 456 'RAISE': tokens.Keyword,457 'RAW': tokens.Keyword,458 'READ': tokens.Keyword,459 'READS': tokens.Keyword,460 'RECHECK': tokens.Keyword,461 'RECURSIVE': tokens.Keyword,462 'REF': tokens.Keyword,463 'REFERENCES': tokens.Keyword,464 'REFERENCING': tokens.Keyword,465 'REINDEX': tokens.Keyword,466 'RELATIVE': tokens.Keyword,467 'RENAME': tokens.Keyword,468 'REPEATABLE': tokens.Keyword,469 'RESET': tokens.Keyword,470 'RESOURCE': tokens.Keyword,471 'RESTART': tokens.Keyword,472 'RESTRICT': tokens.Keyword,473 'RESULT': tokens.Keyword,474 'RETURN': tokens.Keyword,475 'RETURNED_LENGTH': tokens.Keyword,476 'RETURNED_OCTET_LENGTH': tokens.Keyword,477 'RETURNED_SQLSTATE': tokens.Keyword,478 'RETURNING': tokens.Keyword,479 'RETURNS': tokens.Keyword,480 'RIGHT': tokens.Keyword,481 'ROLE': tokens.Keyword,482 'ROLLBACK': tokens.Keyword.DML,483 'ROLLUP': tokens.Keyword,484 'ROUTINE': tokens.Keyword,485 'ROUTINE_CATALOG': tokens.Keyword,486 'ROUTINE_NAME': tokens.Keyword,487 'ROUTINE_SCHEMA': tokens.Keyword,488 'ROWS': tokens.Keyword,489 'ROW_COUNT': tokens.Keyword,490 'RULE': tokens.Keyword,491 492 'SAVE_POINT': tokens.Keyword,493 'SCALE': tokens.Keyword,494 'SCHEMA': tokens.Keyword,495 'SCHEMA_NAME': tokens.Keyword,496 'SCOPE': tokens.Keyword,497 'SCROLL': tokens.Keyword,498 'SEARCH': tokens.Keyword,499 'SECOND': tokens.Keyword,500 'SECURITY': tokens.Keyword,501 'SELF': tokens.Keyword,502 'SENSITIVE': tokens.Keyword,503 'SEQUENCE': tokens.Keyword,504 'SERIALIZABLE': tokens.Keyword,505 'SERVER_NAME': tokens.Keyword,506 'SESSION': tokens.Keyword,507 'SESSION_USER': tokens.Keyword,508 'SETOF': tokens.Keyword,509 'SETS': tokens.Keyword,510 'SHARE': tokens.Keyword,511 'SHOW': tokens.Keyword,512 'SIMILAR': tokens.Keyword,513 'SIMPLE': tokens.Keyword,514 'SIZE': tokens.Keyword,515 'SOME': tokens.Keyword,516 'SOURCE': tokens.Keyword,517 'SPACE': tokens.Keyword,518 'SPECIFIC': tokens.Keyword,519 'SPECIFICTYPE': tokens.Keyword,520 'SPECIFIC_NAME': tokens.Keyword,521 'SQL': tokens.Keyword,522 'SQLBUF': tokens.Keyword,523 'SQLCODE': tokens.Keyword,524 'SQLERROR': tokens.Keyword,525 'SQLEXCEPTION': tokens.Keyword,526 'SQLSTATE': tokens.Keyword,527 'SQLWARNING': tokens.Keyword,528 'STABLE': tokens.Keyword,529 'START': tokens.Keyword.DML,530 # 'STATE': tokens.Keyword,531 'STATEMENT': tokens.Keyword,532 'STATIC': tokens.Keyword,533 'STATISTICS': tokens.Keyword,534 'STDIN': tokens.Keyword,535 'STDOUT': tokens.Keyword,536 'STORAGE': tokens.Keyword,537 'STRICT': tokens.Keyword,538 'STRUCTURE': tokens.Keyword,539 'STYPE': tokens.Keyword,540 'SUBCLASS_ORIGIN': tokens.Keyword,541 'SUBLIST': tokens.Keyword,542 'SUBSTRING': tokens.Keyword,543 'SUCCESSFUL': tokens.Keyword,544 'SUM': tokens.Keyword,545 'SYMMETRIC': tokens.Keyword,546 'SYNONYM': tokens.Keyword,547 'SYSID': tokens.Keyword,548 'SYSTEM': tokens.Keyword,549 'SYSTEM_USER': tokens.Keyword,550 551 'TABLE': tokens.Keyword,552 'TABLE_NAME': tokens.Keyword,553 'TEMP': tokens.Keyword,554 'TEMPLATE': tokens.Keyword,555 'TEMPORARY': tokens.Keyword,556 'TERMINATE': tokens.Keyword,557 'THAN': tokens.Keyword,558 'TIMESTAMP': tokens.Keyword,559 'TIMEZONE_HOUR': tokens.Keyword,560 'TIMEZONE_MINUTE': tokens.Keyword,561 'TO': tokens.Keyword,562 'TOAST': tokens.Keyword,563 'TRAILING': tokens.Keyword,564 'TRANSATION': tokens.Keyword,565 'TRANSACTIONS_COMMITTED': tokens.Keyword,566 'TRANSACTIONS_ROLLED_BACK': tokens.Keyword,567 'TRANSATION_ACTIVE': tokens.Keyword,568 'TRANSFORM': tokens.Keyword,569 'TRANSFORMS': tokens.Keyword,570 'TRANSLATE': tokens.Keyword,571 'TRANSLATION': tokens.Keyword,572 'TREAT': tokens.Keyword,573 'TRIGGER': tokens.Keyword,574 'TRIGGER_CATALOG': tokens.Keyword,575 'TRIGGER_NAME': tokens.Keyword,576 'TRIGGER_SCHEMA': tokens.Keyword,577 'TRIM': tokens.Keyword,578 'TRUE': tokens.Keyword,579 'TRUSTED': tokens.Keyword,580 'TYPE': tokens.Keyword,581 582 'UID': tokens.Keyword,583 'UNCOMMITTED': tokens.Keyword,584 'UNDER': tokens.Keyword,585 'UNENCRYPTED': tokens.Keyword,586 'UNION': tokens.Keyword,587 'UNIQUE': tokens.Keyword,588 'UNKNOWN': tokens.Keyword,589 'UNLISTEN': tokens.Keyword,590 'UNNAMED': tokens.Keyword,591 'UNNEST': tokens.Keyword,592 'UNTIL': tokens.Keyword,593 'UPPER': tokens.Keyword,594 'USAGE': tokens.Keyword,595 'USE': tokens.Keyword,596 'USER': tokens.Keyword,597 'USER_DEFINED_TYPE_CATALOG': tokens.Keyword,598 'USER_DEFINED_TYPE_NAME': tokens.Keyword,599 'USER_DEFINED_TYPE_SCHEMA': tokens.Keyword,600 'USING': tokens.Keyword,601 602 'VACUUM': tokens.Keyword,603 'VALID': tokens.Keyword,604 'VALIDATE': tokens.Keyword,605 'VALIDATOR': tokens.Keyword,606 'VALUES': tokens.Keyword,607 'VARIABLE': tokens.Keyword,608 'VERBOSE': tokens.Keyword,609 'VERSION': tokens.Keyword,610 'VIEW': tokens.Keyword,611 'VOLATILE': tokens.Keyword,612 613 'WEEK': tokens.Keyword,614 'WHENEVER': tokens.Keyword,615 'WITH': tokens.Keyword.CTE,616 'WITHOUT': tokens.Keyword,617 'WORK': tokens.Keyword,618 'WRITE': tokens.Keyword,619 620 'YEAR': tokens.Keyword,621 622 'ZONE': tokens.Keyword,623 624 # Name.Builtin625 'ARRAY': tokens.Name.Builtin,626 'BIGINT': tokens.Name.Builtin,627 'BINARY': tokens.Name.Builtin,628 'BIT': tokens.Name.Builtin,629 'BLOB': tokens.Name.Builtin,630 'BOOLEAN': tokens.Name.Builtin,631 'CHAR': tokens.Name.Builtin,632 'CHARACTER': tokens.Name.Builtin,633 'DATE': tokens.Name.Builtin,634 'DEC': tokens.Name.Builtin,635 'DECIMAL': tokens.Name.Builtin,636 'FILE_TYPE': tokens.Name.Builtin,637 'FLOAT': tokens.Name.Builtin,638 'INT': tokens.Name.Builtin,639 'INT8': tokens.Name.Builtin,640 'INTEGER': tokens.Name.Builtin,641 'INTERVAL': tokens.Name.Builtin,642 'LONG': tokens.Name.Builtin,643 'NATURALN': tokens.Name.Builtin,644 'NVARCHAR': tokens.Name.Builtin,645 'NUMBER': tokens.Name.Builtin,646 'NUMERIC': tokens.Name.Builtin,647 'PLS_INTEGER': tokens.Name.Builtin,648 'POSITIVE': tokens.Name.Builtin,649 'POSITIVEN': tokens.Name.Builtin,650 'REAL': tokens.Name.Builtin,651 'ROWID': tokens.Name.Builtin,652 'ROWLABEL': tokens.Name.Builtin,653 'ROWNUM': tokens.Name.Builtin,654 'SERIAL': tokens.Name.Builtin,655 'SERIAL8': tokens.Name.Builtin,656 'SIGNED': tokens.Name.Builtin,657 'SIGNTYPE': tokens.Name.Builtin,658 'SIMPLE_DOUBLE': tokens.Name.Builtin,659 'SIMPLE_FLOAT': tokens.Name.Builtin,660 'SIMPLE_INTEGER': tokens.Name.Builtin,661 'SMALLINT': tokens.Name.Builtin,662 'SYS_REFCURSOR': tokens.Name.Builtin,663 'SYSDATE': tokens.Name,664 'TEXT': tokens.Name.Builtin,665 'TINYINT': tokens.Name.Builtin,666 'UNSIGNED': tokens.Name.Builtin,667 'UROWID': tokens.Name.Builtin,668 'UTL_FILE': tokens.Name.Builtin,669 'VARCHAR': tokens.Name.Builtin,670 'VARCHAR2': tokens.Name.Builtin,671 'VARYING': tokens.Name.Builtin,672}673 674KEYWORDS_COMMON = {675 'SELECT': tokens.Keyword.DML,676 'INSERT': tokens.Keyword.DML,677 'DELETE': tokens.Keyword.DML,678 'UPDATE': tokens.Keyword.DML,679 'UPSERT': tokens.Keyword.DML,680 'REPLACE': tokens.Keyword.DML,681 'MERGE': tokens.Keyword.DML,682 'DROP': tokens.Keyword.DDL,683 'CREATE': tokens.Keyword.DDL,684 'ALTER': tokens.Keyword.DDL,685 'TRUNCATE': tokens.Keyword.DDL,686 'GRANT': tokens.Keyword.DCL,687 'REVOKE': tokens.Keyword.DCL,688 689 'WHERE': tokens.Keyword,690 'FROM': tokens.Keyword,691 'INNER': tokens.Keyword,692 'JOIN': tokens.Keyword,693 'STRAIGHT_JOIN': tokens.Keyword,694 'AND': tokens.Keyword,695 'OR': tokens.Keyword,696 'LIKE': tokens.Keyword,697 'ON': tokens.Keyword,698 'IN': tokens.Keyword,699 'SET': tokens.Keyword,700 701 'BY': tokens.Keyword,702 'GROUP': tokens.Keyword,703 'ORDER': tokens.Keyword,704 'LEFT': tokens.Keyword,705 'OUTER': tokens.Keyword,706 'FULL': tokens.Keyword,707 708 'IF': tokens.Keyword,709 'END': tokens.Keyword,710 'THEN': tokens.Keyword,711 'LOOP': tokens.Keyword,712 'AS': tokens.Keyword,713 'ELSE': tokens.Keyword,714 'FOR': tokens.Keyword,715 'WHILE': tokens.Keyword,716 717 'CASE': tokens.Keyword,718 'WHEN': tokens.Keyword,719 'MIN': tokens.Keyword,720 'MAX': tokens.Keyword,721 'DISTINCT': tokens.Keyword,722}723 724KEYWORDS_ORACLE = {725 'ARCHIVE': tokens.Keyword,726 'ARCHIVELOG': tokens.Keyword,727 728 'BACKUP': tokens.Keyword,729 'BECOME': tokens.Keyword,730 'BLOCK': tokens.Keyword,731 'BODY': tokens.Keyword,732 733 'CANCEL': tokens.Keyword,734 'CHANGE': tokens.Keyword,735 'COMPILE': tokens.Keyword,736 'CONTENTS': tokens.Keyword,737 'CONTROLFILE': tokens.Keyword,738 739 'DATAFILE': tokens.Keyword,740 'DBA': tokens.Keyword,741 'DISMOUNT': tokens.Keyword,742 'DOUBLE': tokens.Keyword,743 'DUMP': tokens.Keyword,744 745 'ELSIF': tokens.Keyword,746 'EVENTS': tokens.Keyword,747 'EXCEPTIONS': tokens.Keyword,748 'EXPLAIN': tokens.Keyword,749 'EXTENT': tokens.Keyword,750 'EXTERNALLY': tokens.Keyword,751 752 'FLUSH': tokens.Keyword,753 'FREELIST': tokens.Keyword,754 'FREELISTS': tokens.Keyword,755 756 # groups seems too common as table name757 # 'GROUPS': tokens.Keyword,758 759 'INDICATOR': tokens.Keyword,760 'INITRANS': tokens.Keyword,761 'INSTANCE': tokens.Keyword,762 763 'LAYER': tokens.Keyword,764 'LINK': tokens.Keyword,765 'LISTS': tokens.Keyword,766 'LOGFILE': tokens.Keyword,767 768 'MANAGE': tokens.Keyword,769 'MANUAL': tokens.Keyword,770 'MAXDATAFILES': tokens.Keyword,771 'MAXINSTANCES': tokens.Keyword,772 'MAXLOGFILES': tokens.Keyword,773 'MAXLOGHISTORY': tokens.Keyword,774 'MAXLOGMEMBERS': tokens.Keyword,775 'MAXTRANS': tokens.Keyword,776 'MINEXTENTS': tokens.Keyword,777 'MODULE': tokens.Keyword,778 'MOUNT': tokens.Keyword,779 780 'NOARCHIVELOG': tokens.Keyword,781 'NOCACHE': tokens.Keyword,782 'NOCYCLE': tokens.Keyword,783 'NOMAXVALUE': tokens.Keyword,784 'NOMINVALUE': tokens.Keyword,785 'NOORDER': tokens.Keyword,786 'NORESETLOGS': tokens.Keyword,787 'NORMAL': tokens.Keyword,788 'NOSORT': tokens.Keyword,789 790 'OPTIMAL': tokens.Keyword,791 'OWN': tokens.Keyword,792 793 'PACKAGE': tokens.Keyword,794 'PARALLEL': tokens.Keyword,795 'PCTINCREASE': tokens.Keyword,796 'PCTUSED': tokens.Keyword,797 'PLAN': tokens.Keyword,798 'PRIVATE': tokens.Keyword,799 'PROFILE': tokens.Keyword,800 801 'QUOTA': tokens.Keyword,802 803 'RECOVER': tokens.Keyword,804 'RESETLOGS': tokens.Keyword,805 'RESTRICTED': tokens.Keyword,806 'REUSE': tokens.Keyword,807 'ROLES': tokens.Keyword,808 809 'SAVEPOINT': tokens.Keyword,810 'SCN': tokens.Keyword,811 'SECTION': tokens.Keyword,812 'SEGMENT': tokens.Keyword,813 'SHARED': tokens.Keyword,814 'SNAPSHOT': tokens.Keyword,815 'SORT': tokens.Keyword,816 'STATEMENT_ID': tokens.Keyword,817 'STOP': tokens.Keyword,818 'SWITCH': tokens.Keyword,819 820 'TABLES': tokens.Keyword,821 'TABLESPACE': tokens.Keyword,822 'THREAD': tokens.Keyword,823 'TIME': tokens.Keyword,824 'TRACING': tokens.Keyword,825 'TRANSACTION': tokens.Keyword,826 'TRIGGERS': tokens.Keyword,827 828 'UNLIMITED': tokens.Keyword,829 'UNLOCK': tokens.Keyword,830}831 832# MySQL833KEYWORDS_MYSQL = {834 'ROW': tokens.Keyword,835}836 837# PostgreSQL Syntax838KEYWORDS_PLPGSQL = {839 'CONFLICT': tokens.Keyword,840 'WINDOW': tokens.Keyword,841 'PARTITION': tokens.Keyword,842 'OVER': tokens.Keyword,843 'PERFORM': tokens.Keyword,844 'NOTICE': tokens.Keyword,845 'PLPGSQL': tokens.Keyword,846 'INHERIT': tokens.Keyword,847 'INDEXES': tokens.Keyword,848 'ON_ERROR_STOP': tokens.Keyword,849 850 'BYTEA': tokens.Keyword,851 'BIGSERIAL': tokens.Keyword,852 'BIT VARYING': tokens.Keyword,853 'BOX': tokens.Keyword,854 'CHARACTER': tokens.Keyword,855 'CHARACTER VARYING': tokens.Keyword,856 'CIDR': tokens.Keyword,857 'CIRCLE': tokens.Keyword,858 'DOUBLE PRECISION': tokens.Keyword,859 'INET': tokens.Keyword,860 'JSON': tokens.Keyword,861 'JSONB': tokens.Keyword,862 'LINE': tokens.Keyword,863 'LSEG': tokens.Keyword,864 'MACADDR': tokens.Keyword,865 'MONEY': tokens.Keyword,866 'PATH': tokens.Keyword,867 'PG_LSN': tokens.Keyword,868 'POINT': tokens.Keyword,869 'POLYGON': tokens.Keyword,870 'SMALLSERIAL': tokens.Keyword,871 'TSQUERY': tokens.Keyword,872 'TSVECTOR': tokens.Keyword,873 'TXID_SNAPSHOT': tokens.Keyword,874 'UUID': tokens.Keyword,875 'XML': tokens.Keyword,876 877 'FOR': tokens.Keyword,878 'IN': tokens.Keyword,879 'LOOP': tokens.Keyword,880}881 882# Hive Syntax883KEYWORDS_HQL = {884 'EXPLODE': tokens.Keyword,885 'DIRECTORY': tokens.Keyword,886 'DISTRIBUTE': tokens.Keyword,887 'INCLUDE': tokens.Keyword,888 'LOCATE': tokens.Keyword,889 'OVERWRITE': tokens.Keyword,890 'POSEXPLODE': tokens.Keyword,891 892 'ARRAY_CONTAINS': tokens.Keyword,893 'CMP': tokens.Keyword,894 'COLLECT_LIST': tokens.Keyword,895 'CONCAT': tokens.Keyword,896 'CONDITION': tokens.Keyword,897 'DATE_ADD': tokens.Keyword,898 'DATE_SUB': tokens.Keyword,899 'DECODE': tokens.Keyword,900 'DBMS_OUTPUT': tokens.Keyword,901 'ELEMENTS': tokens.Keyword,902 'EXCHANGE': tokens.Keyword,903 'EXTENDED': tokens.Keyword,904 'FLOOR': tokens.Keyword,905 'FOLLOWING': tokens.Keyword,906 'FROM_UNIXTIME': tokens.Keyword,907 'FTP': tokens.Keyword,908 'HOUR': tokens.Keyword,909 'INLINE': tokens.Keyword,910 'INSTR': tokens.Keyword,911 'LEN': tokens.Keyword,912 'MAP': tokens.Name.Builtin,913 'MAXELEMENT': tokens.Keyword,914 'MAXINDEX': tokens.Keyword,915 'MAX_PART_DATE': tokens.Keyword,916 'MAX_PART_INT': tokens.Keyword,917 'MAX_PART_STRING': tokens.Keyword,918 'MINELEMENT': tokens.Keyword,919 'MININDEX': tokens.Keyword,920 'MIN_PART_DATE': tokens.Keyword,921 'MIN_PART_INT': tokens.Keyword,922 'MIN_PART_STRING': tokens.Keyword,923 'NOW': tokens.Keyword,924 'NVL': tokens.Keyword,925 'NVL2': tokens.Keyword,926 'PARSE_URL_TUPLE': tokens.Keyword,927 'PART_LOC': tokens.Keyword,928 'PART_COUNT': tokens.Keyword,929 'PART_COUNT_BY': tokens.Keyword,930 'PRINT': tokens.Keyword,931 'PUT_LINE': tokens.Keyword,932 'RANGE': tokens.Keyword,933 'REDUCE': tokens.Keyword,934 'REGEXP_REPLACE': tokens.Keyword,935 'RESIGNAL': tokens.Keyword,936 'RTRIM': tokens.Keyword,937 'SIGN': tokens.Keyword,938 'SIGNAL': tokens.Keyword,939 'SIN': tokens.Keyword,940 'SPLIT': tokens.Keyword,941 'SQRT': tokens.Keyword,942 'STACK': tokens.Keyword,943 'STR': tokens.Keyword,944 'STRING': tokens.Name.Builtin,945 'STRUCT': tokens.Name.Builtin,946 'SUBSTR': tokens.Keyword,947 'SUMMARY': tokens.Keyword,948 'TBLPROPERTIES': tokens.Keyword,949 'TIMESTAMP': tokens.Name.Builtin,950 'TIMESTAMP_ISO': tokens.Keyword,951 'TO_CHAR': tokens.Keyword,952 'TO_DATE': tokens.Keyword,953 'TO_TIMESTAMP': tokens.Keyword,954 'TRUNC': tokens.Keyword,955 'UNBOUNDED': tokens.Keyword,956 'UNIQUEJOIN': tokens.Keyword,957 'UNIX_TIMESTAMP': tokens.Keyword,958 'UTC_TIMESTAMP': tokens.Keyword,959 'VIEWS': tokens.Keyword,960 961 'EXIT': tokens.Keyword,962 'BREAK': tokens.Keyword,963 'LEAVE': tokens.Keyword,964}965 966 967KEYWORDS_MSACCESS = {968 'DISTINCTROW': tokens.Keyword,969}970 971 972KEYWORDS_SNOWFLAKE = {973 'ACCOUNT': tokens.Keyword,974 'GSCLUSTER': tokens.Keyword,975 'ISSUE': tokens.Keyword,976 'ORGANIZATION': tokens.Keyword,977 'PIVOT': tokens.Keyword,978 'QUALIFY': tokens.Keyword,979 'REGEXP': tokens.Keyword,980 'RLIKE': tokens.Keyword,981 'SAMPLE': tokens.Keyword,982 'TRY_CAST': tokens.Keyword,983 'UNPIVOT': tokens.Keyword,984 985 'VARIANT': tokens.Name.Builtin,986}987 988 989KEYWORDS_BIGQUERY = {990 'ASSERT_ROWS_MODIFIED': tokens.Keyword,991 'DEFINE': tokens.Keyword,992 'ENUM': tokens.Keyword,993 'HASH': tokens.Keyword,994 'LOOKUP': tokens.Keyword,995 'PRECEDING': tokens.Keyword,996 'PROTO': tokens.Keyword,997 'RESPECT': tokens.Keyword,998 'TABLESAMPLE': tokens.Keyword,999 1000 'BIGNUMERIC': tokens.Name.Builtin,1001}1002 