stl.pat.in revision 8cfa702f803c5ef6a2b062a489a1b2cf66b45b5e
1# format : 2# $name = "regular_definition" 3# "pattern" = "substitued_pattern" 4# pattern can contain reference to regular definition with ${name} 5# this occurence are substitued in pattern by their definition 6 7# regular_definition containing other regular_definition refer always to a 8# previously defined regular definition so they can look like recursive but are 9# not. op_regex.cpp do sucessive apply of pattern whilst change occur (with a 10# hard limit on number of subsitutions) so you can apply successive change to 11# translate first to an intermediate simplified form then continue substitution 12# in another pattern (see iosfwd section). The number of grouping regexp is 13# limited, see static const size_t max_match; in op_regex.h. Note than mangled 14# name produce can be illegal as I choose to output like vector<type<T>> rather 15# than vector<type<T> > 16 17# man regex is a friend, is it your ? 18 19$integer = "\<[0-9]+" 20$identifier = "\<[_a-zA-Z][_a-zA-Z0-9]*" 21$typename = "${identifier}(::${identifier})*" 22$typename = "${typename}(<${typename}(, ${typename})*>)*" 23# adding more substitution allow more nested templated type but we run out of 24# \digit which is a wall. Indeed if you add more () grouping you need to 25# rename all relevant \digit in pattern which use this regular definition 26# $typename = "${typename}(<${typename}(, ${typename})*>)*" 27# finally add standard C type not recognized by above patterns, the way to add 28# pointer is ugly but we can't add any grouping to not overrun 9 max group 29# in left pattern rules side.. 30$typename = "(${typename}[ ]*\**|unsigned short[ ]**\**|unsigned int[ ]*\**|unsigned long[ ]*\**|unsigned char[ ]*\**|signed char[ ]*\**|long long[ ]*\**|unsigned long long[ ]*\**|long double[ ]*\**)" 31 32# FIXME: really discussable but simplify output and the next pattern. 33"\<std::" = "" 34" >" = ">" 35# for these two we can't match begin of word. 36"\{anonymous\}::" = "" 37"\(anonymous namespace\)::" = "" 38 39# specific to gcc 2.95 40"\<basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0>>" = "string" 41# two pass, first shrink allocator<> then less<> allowing map with user defined 42# comparator 43"\<(multi)?map<${typename}, ${typename}, ${typename}, allocator<\8>>" = "\1map<\2, \8, \e>" 44"\<(multi)?map<${typename}, ${typename}, less<\2>>" = "\1map<\2, \8>" 45 46"\<bitset<(${integer}), unsigned long>" = "bitset<\1>" 47"\<([io]stream_iterator)<char, @PTRDIFF_T_TYPE@>" = "\1<char>" 48 49# common to all supported gcc version. 50"\<deque<${typename}, allocator<\1>, 0>" = "deque<\1>" 51"\<(stack|queue)<${typename}, deque<\2>>" = "\1<\2>" 52"\<(vector|list|deque)<${typename}, allocator<\2>>" = "\1<\2>" 53# strictly speaking 3rd parameters is less<ContainerType::value_type> 54"\<priority_queue<${typename}, vector<\1>, less<\1>>" = "priority_queue<\1>" 55# two pass, first shrink allocator<> then less<> allowing map with user defined 56# comparator 57"\<(multi)?set<${typename}, ${typename}, allocator<\2>>" = "\1set<\2, \8>" 58"\<(multi)?set<${typename}, less<\2>>" = "\1set<\2>" 59 60# get ride of _Rb_tree iterator typedef, these are also mapped by map/set but 61# we can't distinguish a set<pair<int, int>>::iterator and a 62# map<int, int>::iterator as they decay to an identical typedef so we don't try 63# to be clever here. 64"\<_Rb_tree_iterator<${typename}, \1 const[ ]*&, \1 const[ ]*\*>" = "_Rb_tree<\1>::const_iterator" 65"\<_Rb_tree_iterator<${typename}, \1[ ]*&, \1[ ]*\*>" = "_Rb_tree<\1>::iterator" 66# important special case for map/multimap iterator 67"\<_Rb_tree_iterator<(pair<${typename} const, ${typename}>), \1 const[ ]*&, \1 const[ ]*\*>" = "_Rb_tree<\1>::const_iterator" 68"\<_Rb_tree_iterator<(pair<${typename} const, ${typename}>), \1[ ]*&, \1[ ]*\*>" = "_Rb_tree<\1>::iterator" 69# 2.95/3.2 set/multiset implementation 70"\<_Rb_tree<${typename}, \1, _Identity<\1>, ${typename}, allocator<\1>>" = "_Rb_tree<\1, \1, _Identity<\1>, \7>" 71"_Rb_tree<${typename}, \1, _Identity<\1>, less<\1>>" = "_Rb_tree<\1, \1, _Identity<\1>>" 72# 2.95 map/multimap implementation 73"\<_Rb_tree<${typename}, pair<\1 const, (${typename}( const)?)>, _Select1st<pair<\1 const, \7>>, less<\1>, allocator<\7>>" = "_Rb_tree<\1, pair<\1 const, \7>, _Select1st<pair<\1 const, \7>>, less<\1>>" 74# 3.2 map/multimap implementation 75"\<_Rb_tree<${typename}, pair<\1 const, ${typename}>, _Select1st<pair<\1 const, \7>>, less<\1>, allocator<pair<\1 const, \7>>>" = "_Rb_tree<\1, pair<\1 const, \7>, _Select1st<pair<\1 const, \7>>, less<\1>>" 76# now we can shrink default comparator. 77"\<_Rb_tree<${typename}, pair<\1 const, (${typename}( const)?)>, _Select1st<pair<\1 const, \7>>, less<\1>>" = "_Rb_tree<\1, pair<\1 const, \7>, _Select1st<pair<\1 const, \7>>>" 78# get rid of _Select1st and _Identity 79# FIXME: the presence od _Identity<> and _Select1st<> allowed to quickly 80# differentiate a set or a map, the rule now to differentiate them is: 81# second parameter to _Rb_tree* is a pair<> ==> map else set<>. Either we need 82# to document this or remove _Identity and _Select1st pattern 83"\<_Identity<${typename}>" = "\1" 84"\<_Select1st<pair<${typename} const, ${typename}( const)?>>" = "\1 const" 85 86"\<_List_base<${typename}, allocator<\1>>" = "_List_base<\1>" 87 88# 2.95 templatized operator<< and >> exist only for std::string 89"\<ostream & operator<<<char, string_char_traits<char>, __default_alloc_template<true, 0>>\(ostream &, string const &\)" = "ostream & operator<<(ostream &, string const &)" 90"\<istream & (operator>>|getline)<char, string_char_traits<char>, __default_alloc_template<true, 0>>\(istream &, string &\)" = "istream & \1(istream &, string &)" 91 92# 3.0 templatized operator<< and >> exist only for std::string 93"\<ostream& operator<< <char, char_traits<char>, allocator<char>>\(ostream&, string const&\)" = "ostream & operator<<(ostream &, string const &)" 94"\<istream& (operator>>|getline) <char, char_traits<char>, allocator<char>>\(istream&, string&\)" = "istream & \1(istream &, string &)" 95 96# 2.95/3.2 algorithm 97"\<(${typename}( const)?) \* find<\1 \*, ${typename}>\(\1 \*, \1 \*, \9 const &, ${typename}\)" = "\1 * find(\1 *, \1 *, \9 const &, \f)" 98 99"\<(${typename}( const)?) \* find_if<\1 \*, ${typename}>\(\1 \*, \1 \*, \9, random_access_iterator_tag)" = "\1 * find_if(\1 *, \1 *, \9, random_access_iterator_tag)" 100 101# gcc 3.2, not tested on 3.0, 3.1 but probably work. 102# FIXME: there is a potential problem here with map<int const, long> 103# the pair become pair<\2, \8> not pair<\2 const, \8>, who use the above, 104# is it legal ? 105# two pass, first shrink allocator<> then less<> allowing map with user defined 106# comparator 107"\<(multi)?map<${typename}, ${typename}, ${typename}, allocator<pair<\2 const, \8>>>" = "\1map<\2, \8, \e>" 108# this one exist already for 2.95 the first transformation giving a common 109# form for 2.95/3.2 110# "\<(multi)?map<${typename}, ${typename}, less<\2>>" = "\1map<\2, \8>" 111 112"\<bitset<\(@SIZE_T_TYPE@\)(${integer})>" = "bitset<\1>" 113 114# iterator 115"\<iterator<(input|output|forward|bidirectional|random)_iterator_tag, ${typename}, (@PTRDIFF_T_TYPE@), \8\*, \8&>" = "iterator<\1_iterator_tag, \2>" 116"\<([io]stream_iterator)<${typename}, char, char_traits<char>, @PTRDIFF_T_TYPE@>" = "\1<\2>" 117 118# __gnu_cxx::__normal_iterator are used in two context: basic_string<> and 119# vector<T> we decay them to string::iterator, vector<T>::iterator 120"\<__gnu_cxx::__normal_iterator<char const\*, string>" = "string::const_iterator" 121"\<__gnu_cxx::__normal_iterator<char\*, string>" = "string::iterator" 122"\<__gnu_cxx::__normal_iterator<wchar_t const\*, wstring>" = "wstring::const_iterator" 123"\<__gnu_cxx::__normal_iterator<wchar_t\*, wstring>" = "wstring::iterator" 124"\<__gnu_cxx::__normal_iterator<${typename} const\*, vector<\1>>" = "vector<\1>::const_iterator" 125"\<__gnu_cxx::__normal_iterator<${typename}\*, vector<\1>>" = "vector<\1>::iterator" 126 127# 2.95 use only _List_iterator, 3.2 use also _List_iterator_base but since 128# list::iterator is a typedef to _List_iterator we don't need to deal with 129# _List_iterator_base 130"\<_List_iterator<${typename}, \1[ ]*&, \1[ ]*\*>" = "list<\1>::iterator" 131"\<_List_iterator<${typename}, \1 const[ ]*&, \1 const[ ]*\*>" = "list<\1>::const_iterator" 132 133# iosfwd, std::string and std::wstring 134# first translate from "basic_xxx<T, char_traits<T>>" to "basic_xxx<T>" 135"\<([io]streambuf_iterator|basic_(ios|streambuf|([io]|io)stream|filebuf|[io]?fstream))<${typename}, char_traits<\4>>" = "\1<\4>" 136# as above translate from "basic_xxx<T, char_traits<T>, ...>" to "basic_xxx<T>" 137"\<basic_(string(buf)?|[io]?stringstream)?<${typename}, char_traits<\3>, allocator<\3>>" = "basic_\1<\3>" 138# now we can translate the two above for char, wchar_t to standardese typedef 139$iosfwd_name = "\<basic_(string|ios|(stream|file|string)buf|(i|o|io)stream|[io]?(fstream|stringstream))" 140"\<${iosfwd_name}<char>" = "\1" 141"\<${iosfwd_name}<wchar_t>" = "w\1" 142 143# streampos and wstreampos decay to the same type, they are undistingushable 144# in mangled name so substitute for the most probable, not a big deal 145"\<fpos<__mbstate_t>" = "streampos" 146 147# locale 148# strictly speaking this accept num_put<..., istream_iterator<...> > or 149# num_get<..., ostream_iterator<...> > but this can't compile so no big deal 150"\<(money|time|num)_(put|get)<${typename}, (i|o)streambuf_iterator<\3>>" = "\1_\2<\3>" 151"\<moneypunct(_byname)?<${typename}, \(bool\)0>" = "moneypunct\1<\2>" 152 153# 3.2 algorithm 154"\<(vector<${typename}>::(const_)?iterator) find<\1, ${typename}>\(\1, \1, \9 const&, ${typename}\)" = "\1 find(\1, \1, \9 const&, \f)" 155 156"\<((string|wstring)::(const_)?iterator) find<\1, ${typename}>\(\1, \1, \4 const&, ${typename}\)" = "\1 find(\1, \1, \4 const&, \a)" 157 158"\<(vector<${typename}>::(const_)?iterator) find_if<\1, ${typename}>\(\1, \1, \9, random_access_iterator_tag\)" = "\1 find_if(\1, \1, \9, random_access_iterator_tag)" 159 160"\<((string|wstring)::(const_)?iterator) find_if<\1, ${typename}>\(\1, \1, \4, random_access_iterator_tag\)" = "\1 find_if(\1, \1, \4, random_access_iterator_tag)" 161