|
1 # -*- coding: utf-8 -*- |
1 """ |
2 """ |
2 pygments.lexers._postgres_builtins |
3 pygments.lexers._postgres_builtins |
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 |
5 |
5 Self-updating data files for PostgreSQL lexer. |
6 Self-updating data files for PostgreSQL lexer. |
6 |
7 |
7 :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. |
8 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
9 """ |
10 """ |
10 |
11 |
11 import re |
12 import re |
12 import urllib.request, urllib.parse, urllib.error |
13 import urllib.request, urllib.parse, urllib.error |
55 # remove all the tags |
55 # remove all the tags |
56 line = re.sub("<replaceable>[^<]+</replaceable>", "", line) |
56 line = re.sub("<replaceable>[^<]+</replaceable>", "", line) |
57 line = re.sub("<[^>]+>", "", line) |
57 line = re.sub("<[^>]+>", "", line) |
58 |
58 |
59 # Drop the parts containing braces |
59 # Drop the parts containing braces |
60 for tmp in [ t for tmp in line.split('[') for t in tmp.split(']') if "(" not in t ]: |
60 for tmp in [t for tmp in line.split('[') |
|
61 for t in tmp.split(']') if "(" not in t]: |
61 for t in tmp.split(','): |
62 for t in tmp.split(','): |
62 t = t.strip() |
63 t = t.strip() |
63 if not t: continue |
64 if not t: continue |
64 dt.add(" ".join(t.split())) |
65 dt.add(" ".join(t.split())) |
65 |
66 |
202 |
203 |
203 DATATYPES = [ |
204 DATATYPES = [ |
204 'bigint', 'bigserial', 'bit', 'bit varying', 'bool', 'boolean', 'box', |
205 'bigint', 'bigserial', 'bit', 'bit varying', 'bool', 'boolean', 'box', |
205 'bytea', 'char', 'character', 'character varying', 'cidr', 'circle', |
206 'bytea', 'char', 'character', 'character varying', 'cidr', 'circle', |
206 'date', 'decimal', 'double precision', 'float4', 'float8', 'inet', |
207 'date', 'decimal', 'double precision', 'float4', 'float8', 'inet', |
207 'int', 'int2', 'int4', 'int8', 'integer', 'interval', 'line', 'lseg', |
208 'int', 'int2', 'int4', 'int8', 'integer', 'interval', 'json', 'line', |
208 'macaddr', 'money', 'numeric', 'path', 'point', 'polygon', 'real', |
209 'lseg', 'macaddr', 'money', 'numeric', 'path', 'point', 'polygon', |
209 'serial', 'serial4', 'serial8', 'smallint', 'text', 'time', 'timestamp', |
210 'real', 'serial', 'serial2', 'serial4', 'serial8', 'smallint', |
210 'timestamptz', 'timetz', 'tsquery', 'tsvector', 'txid_snapshot', 'uuid', |
211 'smallserial', 'text', 'time', 'timestamp', 'timestamptz', 'timetz', |
211 'varbit', 'varchar', 'with time zone', 'without time zone', 'xml', |
212 'tsquery', 'tsvector', 'txid_snapshot', 'uuid', 'varbit', 'varchar', |
|
213 'with time zone', 'without time zone', 'xml', |
212 ] |
214 ] |
213 |
215 |
214 PSEUDO_TYPES = [ |
216 PSEUDO_TYPES = [ |
215 'any', 'anyarray', 'anyelement', 'anyenum', 'anynonarray', 'cstring', |
217 'any', 'anyelement', 'anyarray', 'anynonarray', 'anyenum', 'anyrange', |
216 'internal', 'language_handler', 'fdw_handler', 'record', 'trigger', |
218 'cstring', 'internal', 'language_handler', 'fdw_handler', 'record', |
217 'void', 'opaque', |
219 'trigger', 'void', 'opaque', |
218 ] |
220 ] |
219 |
221 |
220 # Remove 'trigger' from types |
222 # Remove 'trigger' from types |
221 PSEUDO_TYPES = sorted(set(PSEUDO_TYPES) - set(map(str.lower, KEYWORDS))) |
223 PSEUDO_TYPES = sorted(set(PSEUDO_TYPES) - set(map(str.lower, KEYWORDS))) |
222 |
224 |