@@ -14,6 +14,7 @@ def is_keyword(value):
1414 val = value .upper ()
1515 return (KEYWORDS_COMMON .get (val ) or
1616 KEYWORDS_ORACLE .get (val ) or
17+ KEYWORDS_PLPGSQL .get (val ) or
1718 KEYWORDS .get (val , tokens .Name )), value
1819
1920
@@ -35,7 +36,7 @@ def is_keyword(value):
3536
3637 (r"`(``|[^`])*`" , tokens .Name ),
3738 (r"´(´´|[^´])*´" , tokens .Name ),
38- (r'(\$(?:[_A-Z ]\w*)?\$)[\s\S]*?\1' , tokens .Literal ),
39+ (r'(\$(?:[_A-ZÀ-Ü ]\w*)?\$)[\s\S]*?\1' , tokens .Literal ),
3940
4041 (r'\?' , tokens .Name .Placeholder ),
4142 (r'%(\(\w+\))?s' , tokens .Name .Placeholder ),
@@ -47,22 +48,20 @@ def is_keyword(value):
4748 # is never a functino, see issue183
4849 (r'(CASE|IN|VALUES|USING)\b' , tokens .Keyword ),
4950
50- (r'(@|##|#)[A-Z ]\w+' , tokens .Name ),
51+ (r'(@|##|#)[A-ZÀ-Ü ]\w+' , tokens .Name ),
5152
5253 # see issue #39
5354 # Spaces around period `schema . name` are valid identifier
5455 # TODO: Spaces before period not implemented
55- (r'[A-Z ]\w*(?=\s*\.)' , tokens .Name ), # 'Name' .
56+ (r'[A-ZÀ-Ü ]\w*(?=\s*\.)' , tokens .Name ), # 'Name' .
5657 # FIXME(atronah): never match,
5758 # because `re.match` doesn't work with lookbehind regexp feature
58- (r'(?<=\.)[A-Z]\w*' , tokens .Name ), # .'Name'
59- (r'[A-Z]\w*(?=\()' , tokens .Name ), # side effect: change kw to func
60-
59+ (r'(?<=\.)[A-ZÀ-Ü]\w*' , tokens .Name ), # .'Name'
60+ (r'[A-ZÀ-Ü]\w*(?=\()' , tokens .Name ), # side effect: change kw to func
6161 (r'-?0x[\dA-F]+' , tokens .Number .Hexadecimal ),
6262 (r'-?\d*(\.\d+)?E-?\d+' , tokens .Number .Float ),
6363 (r'-?(\d+(\.\d*)|\.\d+)' , tokens .Number .Float ),
64- (r'-?\d+' , tokens .Number .Integer ),
65-
64+ (r'-?\d+(?![_A-ZÀ-Ü])' , tokens .Number .Integer ),
6665 (r"'(''|\\\\|\\'|[^'])*'" , tokens .String .Single ),
6766 # not a real string literal in ANSI SQL:
6867 (r'(""|".*?[^\\]")' , tokens .String .Symbol ),
@@ -78,7 +77,7 @@ def is_keyword(value):
7877 (r'CREATE(\s+OR\s+REPLACE)?\b' , tokens .Keyword .DDL ),
7978 (r'DOUBLE\s+PRECISION\b' , tokens .Name .Builtin ),
8079
81- (r'[_A-Z ][_$#\w]*' , is_keyword ),
80+ (r'[0-9_A-ZÀ-Ü ][_$#\w]*' , is_keyword ),
8281
8382 (r'[;:()\[\],\.]' , tokens .Punctuation ),
8483 (r'[<>=~!]+' , tokens .Operator .Comparison ),
@@ -115,6 +114,7 @@ def is_keyword(value):
115114 'ATOMIC' : tokens .Keyword ,
116115 'AUDIT' : tokens .Keyword ,
117116 'AUTHORIZATION' : tokens .Keyword ,
117+ 'AUTO_INCREMENT' : tokens .Keyword ,
118118 'AVG' : tokens .Keyword ,
119119
120120 'BACKWARD' : tokens .Keyword ,
@@ -143,6 +143,7 @@ def is_keyword(value):
143143 'CHARACTER_SET_NAME' : tokens .Keyword ,
144144 'CHARACTER_SET_SCHEMA' : tokens .Keyword ,
145145 'CHAR_LENGTH' : tokens .Keyword ,
146+ 'CHARSET' : tokens .Keyword ,
146147 'CHECK' : tokens .Keyword ,
147148 'CHECKED' : tokens .Keyword ,
148149 'CHECKPOINT' : tokens .Keyword ,
@@ -239,6 +240,7 @@ def is_keyword(value):
239240 'ENCODING' : tokens .Keyword ,
240241 'ENCRYPTED' : tokens .Keyword ,
241242 'END-EXEC' : tokens .Keyword ,
243+ 'ENGINE' : tokens .Keyword ,
242244 'EQUALS' : tokens .Keyword ,
243245 'ESCAPE' : tokens .Keyword ,
244246 'EVERY' : tokens .Keyword ,
@@ -637,7 +639,7 @@ def is_keyword(value):
637639 'SERIAL8' : tokens .Name .Builtin ,
638640 'SIGNED' : tokens .Name .Builtin ,
639641 'SMALLINT' : tokens .Name .Builtin ,
640- 'SYSDATE' : tokens .Name . Builtin ,
642+ 'SYSDATE' : tokens .Name ,
641643 'TEXT' : tokens .Name .Builtin ,
642644 'TINYINT' : tokens .Name .Builtin ,
643645 'UNSIGNED' : tokens .Name .Builtin ,
@@ -798,3 +800,18 @@ def is_keyword(value):
798800 'UNLIMITED' : tokens .Keyword ,
799801 'UNLOCK' : tokens .Keyword ,
800802}
803+
804+ # PostgreSQL Syntax
805+ KEYWORDS_PLPGSQL = {
806+ 'PARTITION' : tokens .Keyword ,
807+ 'OVER' : tokens .Keyword ,
808+ 'PERFORM' : tokens .Keyword ,
809+ 'NOTICE' : tokens .Keyword ,
810+ 'PLPGSQL' : tokens .Keyword ,
811+ 'INHERIT' : tokens .Keyword ,
812+ 'INDEXES' : tokens .Keyword ,
813+
814+ 'FOR' : tokens .Keyword ,
815+ 'IN' : tokens .Keyword ,
816+ 'LOOP' : tokens .Keyword ,
817+ }
0 commit comments