On 24. Oct 2006, at 21:31, Timothy Bates wrote:
So a suggestion for whomever maintains the sql bundle: can we change the simple regexp for storage type to a capture type.
I think something like this? [...]
Well, because of how the commands have different use of integers, it ends up being a lot of captures, but I “unfolded” it into the rule below.
Looking at that pattern though, I wonder if the last brahcn shouldn’t use \s instead of s?
I.e. with s it matches: ‘timestamps(42) withoutstimeszone’ instead of ‘timestamp (42) withoutstimeszone’.
{ match = '(?xi)
# normal stuff, capture 1 \b(bigint|bigserial|bit|boolean|box|bytea|cidr|circle|date| double\sprecision|inet|int|integer|line|lseg|macaddr|money|oid|path| point|polygon|real|serial|smallint|sysdate|text)\b
# numeric suffix, capture 2 + 3i |\b(bit\svarying|character\s(?:varying)?|tinyint|var\schar| float|interval)((\d+))
# optional numeric suffix, capture 4 + 5i |\b(char|number|varchar\d?)\b(?:((\d+)))?
# special case, capture 6 + 7i + 8i |\b(numeric)\b(?:((\d+),(\d+)))?
# special case, captures 9, 10i, 11 |\b(times)(?:((\d+)))(\swithoutstimeszone\b)?
# special case, captures 12, 13, 14i, 15 |\b(timestamp)(?:(s)((\d+))(\swithoutstimeszone\b)?)?
'; captures = { 1 = { name = 'storage.type.sql'; }; 2 = { name = 'storage.type.sql'; }; 3 = { name = 'constant.numeric.sql'; }; 4 = { name = 'storage.type.sql'; }; 5 = { name = 'constant.numeric.sql'; }; 6 = { name = 'storage.type.sql'; }; 7 = { name = 'constant.numeric.sql'; }; 8 = { name = 'constant.numeric.sql'; }; 9 = { name = 'storage.type.sql'; }; 10 = { name = 'constant.numeric.sql'; }; 11 = { name = 'storage.type.sql'; }; 12 = { name = 'storage.type.sql'; }; 13 = { name = 'storage.type.sql'; }; 14 = { name = 'constant.numeric.sql'; }; 15 = { name = 'storage.type.sql'; }; }; },