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$ptrdiff_t_type = "(int|long)" 32 33 34# FIXME: really discussable but simplify output and the next pattern. 35"\<std::" = "" 36" >" = ">" 37# for these two we can't match begin of word. 38"\{anonymous\}::" = "" 39"\(anonymous namespace\)::" = "" 40 41# specific to gcc 2.95 42"\<basic_string<char, string_char_traits<char>, __default_alloc_template<true, 0>>" = "string" 43# two pass, first shrink allocator<> then less<> allowing map with user defined 44# comparator 45"\<(multi)?map<${typename}, ${typename}, ${typename}, allocator<\8>>" = "\1map<\2, \8, \e>" 46"\<(multi)?map<${typename}, ${typename}, less<\2>>" = "\1map<\2, \8>" 47 48"\<bitset<(${integer}), unsigned long>" = "bitset<\1>" 49"\<([io]stream_iterator)<char, ${ptrdiff_t_type}>" = "\1<char>" 50 51# common to all supported gcc version. 52"\<deque<${typename}, allocator<\1>, 0>" = "deque<\1>" 53"\<(stack|queue)<${typename}, deque<\2>>" = "\1<\2>" 54"\<(vector|list|deque)<${typename}, allocator<\2>>" = "\1<\2>" 55# strictly speaking 3rd parameters is less<ContainerType::value_type> 56"\<priority_queue<${typename}, vector<\1>, less<\1>>" = "priority_queue<\1>" 57# two pass, first shrink allocator<> then less<> allowing map with user defined 58# comparator 59"\<(multi)?set<${typename}, ${typename}, allocator<\2>>" = "\1set<\2, \8>" 60"\<(multi)?set<${typename}, less<\2>>" = "\1set<\2>" 61 62# get ride of _Rb_tree iterator typedef, these are also mapped by map/set but 63# we can't distinguish a set<pair<int, int>>::iterator and a 64# map<int, int>::iterator as they decay to an identical typedef so we don't try 65# to be clever here. 66"\<_Rb_tree_iterator<${typename}, \1 const[ ]*&, \1 const[ ]*\*>" = "_Rb_tree<\1>::const_iterator" 67"\<_Rb_tree_iterator<${typename}, \1[ ]*&, \1[ ]*\*>" = "_Rb_tree<\1>::iterator" 68# important special case for map/multimap iterator 69"\<_Rb_tree_iterator<(pair<${typename} const, ${typename}>), \1 const[ ]*&, \1 const[ ]*\*>" = "_Rb_tree<\1>::const_iterator" 70"\<_Rb_tree_iterator<(pair<${typename} const, ${typename}>), \1[ ]*&, \1[ ]*\*>" = "_Rb_tree<\1>::iterator" 71# 2.95/3.2 set/multiset implementation 72"\<_Rb_tree<${typename}, \1, _Identity<\1>, ${typename}, allocator<\1>>" = "_Rb_tree<\1, \1, _Identity<\1>, \7>" 73"_Rb_tree<${typename}, \1, _Identity<\1>, less<\1>>" = "_Rb_tree<\1, \1, _Identity<\1>>" 74# 2.95 map/multimap implementation 75"\<_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>>" 76# 3.2 map/multimap implementation 77"\<_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>>" 78# now we can shrink default comparator. 79"\<_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>>>" 80# get rid of _Select1st and _Identity 81# FIXME: the presence od _Identity<> and _Select1st<> allowed to quickly 82# differentiate a set or a map, the rule now to differentiate them is: 83# second parameter to _Rb_tree* is a pair<> ==> map else set<>. Either we need 84# to document this or remove _Identity and _Select1st pattern 85"\<_Identity<${typename}>" = "\1" 86"\<_Select1st<pair<${typename} const, ${typename}( const)?>>" = "\1 const" 87 88"\<_List_base<${typename}, allocator<\1>>" = "_List_base<\1>" 89 90# 2.95 templatized operator<< and >> exist only for std::string 91"\<ostream & operator<<<char, string_char_traits<char>, __default_alloc_template<true, 0>>\(ostream &, string const &\)" = "ostream & operator<<(ostream &, string const &)" 92"\<istream & (operator>>|getline)<char, string_char_traits<char>, __default_alloc_template<true, 0>>\(istream &, string &\)" = "istream & \1(istream &, string &)" 93 94# 3.0 templatized operator<< and >> exist only for std::string 95"\<ostream& operator<< <char, char_traits<char>, allocator<char>>\(ostream&, string const&\)" = "ostream & operator<<(ostream &, string const &)" 96"\<istream& (operator>>|getline) <char, char_traits<char>, allocator<char>>\(istream&, string&\)" = "istream & \1(istream &, string &)" 97 98# 2.95/3.2 algorithm 99"\<(${typename}( const)?) \* find<\1 \*, ${typename}>\(\1 \*, \1 \*, \9 const &, ${typename}\)" = "\1 * find(\1 *, \1 *, \9 const &, \f)" 100 101"\<(${typename}( const)?) \* find_if<\1 \*, ${typename}>\(\1 \*, \1 \*, \9, random_access_iterator_tag)" = "\1 * find_if(\1 *, \1 *, \9, random_access_iterator_tag)" 102 103# gcc 3.2, not tested on 3.0, 3.1 but probably work. 104# FIXME: there is a potential problem here with map<int const, long> 105# the pair become pair<\2, \8> not pair<\2 const, \8>, who use the above, 106# is it legal ? 107# two pass, first shrink allocator<> then less<> allowing map with user defined 108# comparator 109"\<(multi)?map<${typename}, ${typename}, ${typename}, allocator<pair<\2 const, \8>>>" = "\1map<\2, \8, \e>" 110# this one exist already for 2.95 the first transformation giving a common 111# form for 2.95/3.2 112# "\<(multi)?map<${typename}, ${typename}, less<\2>>" = "\1map<\2, \8>" 113 114"\<bitset<\(unsigned( long)?\)(${integer})>" = "bitset<\2>" 115 116# iterator 117"\<iterator<(input|output|forward|bidirectional|random)_iterator_tag, ${typename}, (${ptrdiff_t_type}), \8\*, \8&>" = "iterator<\1_iterator_tag, \2>" 118"\<([io]stream_iterator)<${typename}, char, char_traits<char>, ${ptrdiff_t_type}>" = "\1<\2>" 119 120# __gnu_cxx::__normal_iterator are used in two context: basic_string<> and 121# vector<T> we decay them to string::iterator, vector<T>::iterator 122"\<__gnu_cxx::__normal_iterator<char const\*, string>" = "string::const_iterator" 123"\<__gnu_cxx::__normal_iterator<char\*, string>" = "string::iterator" 124"\<__gnu_cxx::__normal_iterator<wchar_t const\*, wstring>" = "wstring::const_iterator" 125"\<__gnu_cxx::__normal_iterator<wchar_t\*, wstring>" = "wstring::iterator" 126"\<__gnu_cxx::__normal_iterator<${typename} const\*, vector<\1>>" = "vector<\1>::const_iterator" 127"\<__gnu_cxx::__normal_iterator<${typename}\*, vector<\1>>" = "vector<\1>::iterator" 128 129# 2.95 use only _List_iterator, 3.2 use also _List_iterator_base but since 130# list::iterator is a typedef to _List_iterator we don't need to deal with 131# _List_iterator_base 132"\<_List_iterator<${typename}, \1[ ]*&, \1[ ]*\*>" = "list<\1>::iterator" 133"\<_List_iterator<${typename}, \1 const[ ]*&, \1 const[ ]*\*>" = "list<\1>::const_iterator" 134 135# iosfwd, std::string and std::wstring 136# first translate from "basic_xxx<T, char_traits<T>>" to "basic_xxx<T>" 137"\<([io]streambuf_iterator|basic_(ios|streambuf|([io]|io)stream|filebuf|[io]?fstream))<${typename}, char_traits<\4>>" = "\1<\4>" 138# as above translate from "basic_xxx<T, char_traits<T>, ...>" to "basic_xxx<T>" 139"\<basic_(string(buf)?|[io]?stringstream)?<${typename}, char_traits<\3>, allocator<\3>>" = "basic_\1<\3>" 140# now we can translate the two above for char, wchar_t to standardese typedef 141$iosfwd_name = "\<basic_(string|ios|(stream|file|string)buf|(i|o|io)stream|[io]?(fstream|stringstream))" 142"\<${iosfwd_name}<char>" = "\1" 143"\<${iosfwd_name}<wchar_t>" = "w\1" 144 145# streampos and wstreampos decay to the same type, they are undistingushable 146# in mangled name so substitute for the most probable, not a big deal 147"\<fpos<__mbstate_t>" = "streampos" 148 149# locale 150# strictly speaking this accept num_put<..., istream_iterator<...> > or 151# num_get<..., ostream_iterator<...> > but this can't compile so no big deal 152"\<(money|time|num)_(put|get)<${typename}, (i|o)streambuf_iterator<\3>>" = "\1_\2<\3>" 153"\<moneypunct(_byname)?<${typename}, \(bool\)0>" = "moneypunct\1<\2>" 154 155# 3.2 algorithm 156"\<(vector<${typename}>::(const_)?iterator) find<\1, ${typename}>\(\1, \1, \9 const&, ${typename}\)" = "\1 find(\1, \1, \9 const&, \f)" 157 158"\<((string|wstring)::(const_)?iterator) find<\1, ${typename}>\(\1, \1, \4 const&, ${typename}\)" = "\1 find(\1, \1, \4 const&, \a)" 159 160"\<(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)" 161 162"\<((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)" 163