Improve the 0.x->1.x converter script (ticket #157)
authorPeter Kovacs <kpeter@inf.elte.hu>
Sat, 18 Oct 2008 11:46:25 +0200
changeset 33594b832d461f7
parent 322 6dbd5184c6a9
child 344 3f9f3550dbf5
Improve the 0.x->1.x converter script (ticket #157)

- Support updating more files at once.
- Much better regexp solution for "whole words only" replacements.
tools/lemon-0.x-to-1.x.sh
     1.1 --- a/tools/lemon-0.x-to-1.x.sh	Sun Oct 12 19:35:48 2008 +0100
     1.2 +++ b/tools/lemon-0.x-to-1.x.sh	Sat Oct 18 11:46:25 2008 +0200
     1.3 @@ -3,125 +3,70 @@
     1.4  set -e
     1.5  
     1.6  if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then
     1.7 -	echo "Usage:"
     1.8 -	echo "  $0 source-file"
     1.9 -	exit
    1.10 +    echo "Usage:"
    1.11 +    echo "  $0 source-file(s)"
    1.12 +    exit
    1.13  fi
    1.14  
    1.15 -TMP=`mktemp`
    1.16 -
    1.17 -sed	-e "s/undirected graph/_gr_aph_label_/g"\
    1.18 -	-e "s/undirected edge/_ed_ge_label_/g"\
    1.19 -	-e "s/graph_/_gr_aph_label__/g"\
    1.20 -	-e "s/_graph/__gr_aph_label_/g"\
    1.21 -	-e "s/UGraph/_Gr_aph_label_/g"\
    1.22 -	-e "s/uGraph/_gr_aph_label_/g"\
    1.23 -	-e "s/ugraph/_gr_aph_label_/g"\
    1.24 -	-e "s/Graph/_Digr_aph_label_/g"\
    1.25 -	-e "s/graph/_digr_aph_label_/g"\
    1.26 -	-e "s/UEdge/_Ed_ge_label_/g"\
    1.27 -	-e "s/uEdge/_ed_ge_label_/g"\
    1.28 -	-e "s/uedge/_ed_ge_label_/g"\
    1.29 -	-e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\
    1.30 -	-e "s/Edge/_Ar_c_label_/g"\
    1.31 -	-e "s/edge/_ar_c_label_/g"\
    1.32 -	-e "s/ANode/_Re_d_label_/g"\
    1.33 -	-e "s/BNode/_Blu_e_label_/g"\
    1.34 -	-e "s/A-Node/_Re_d_label_/g"\
    1.35 -	-e "s/B-Node/_Blu_e_label_/g"\
    1.36 -	-e "s/anode/_re_d_label_/g"\
    1.37 -	-e "s/bnode/_blu_e_label_/g"\
    1.38 -	-e "s/aNode/_re_d_label_/g"\
    1.39 -	-e "s/bNode/_blu_e_label_/g"\
    1.40 -	-e "s/_Digr_aph_label_/Digraph/g"\
    1.41 -	-e "s/_digr_aph_label_/digraph/g"\
    1.42 -	-e "s/_Gr_aph_label_/Graph/g"\
    1.43 -	-e "s/_gr_aph_label_/graph/g"\
    1.44 -	-e "s/_Ar_c_label_/Arc/g"\
    1.45 -	-e "s/_ar_c_label_/arc/g"\
    1.46 -	-e "s/_Ed_ge_label_/Edge/g"\
    1.47 -	-e "s/_ed_ge_label_/edge/g"\
    1.48 -	-e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
    1.49 -	-e "s/_Re_d_label_/Red/g"\
    1.50 -	-e "s/_Blu_e_label_/Blue/g"\
    1.51 -	-e "s/_re_d_label_/red/g"\
    1.52 -	-e "s/_blu_e_label_/blue/g"\
    1.53 -	-e "s/\(\W\)DefPredMap\(\W\)/\1SetPredMap\2/g"\
    1.54 -	-e "s/\(\W\)DefPredMap$/\1SetPredMap/g"\
    1.55 -	-e "s/^DefPredMap\(\W\)/SetPredMap\1/g"\
    1.56 -	-e "s/^DefPredMap$/SetPredMap/g"\
    1.57 -	-e "s/\(\W\)DefDistMap\(\W\)/\1SetDistMap\2/g"\
    1.58 -	-e "s/\(\W\)DefDistMap$/\1SetDistMap/g"\
    1.59 -	-e "s/^DefDistMap\(\W\)/SetDistMap\1/g"\
    1.60 -	-e "s/^DefDistMap$/SetDistMap/g"\
    1.61 -	-e "s/\(\W\)DefReachedMap\(\W\)/\1SetReachedMap\2/g"\
    1.62 -	-e "s/\(\W\)DefReachedMap$/\1SetReachedMap/g"\
    1.63 -	-e "s/^DefReachedMap\(\W\)/SetReachedMap\1/g"\
    1.64 -	-e "s/^DefReachedMap$/SetReachedMap/g"\
    1.65 -	-e "s/\(\W\)DefProcessedMap\(\W\)/\1SetProcessedMap\2/g"\
    1.66 -	-e "s/\(\W\)DefProcessedMap$/\1SetProcessedMap/g"\
    1.67 -	-e "s/^DefProcessedMap\(\W\)/SetProcessedMap\1/g"\
    1.68 -	-e "s/^DefProcessedMap$/SetProcessedMap/g"\
    1.69 -	-e "s/\(\W\)DefHeap\(\W\)/\1SetHeap\2/g"\
    1.70 -	-e "s/\(\W\)DefHeap$/\1SetHeap/g"\
    1.71 -	-e "s/^DefHeap\(\W\)/SetHeap\1/g"\
    1.72 -	-e "s/^DefHeap$/SetHeap/g"\
    1.73 -	-e "s/\(\W\)DefStandardHeap\(\W\)/\1SetStandradHeap\2/g"\
    1.74 -	-e "s/\(\W\)DefStandardHeap$/\1SetStandradHeap/g"\
    1.75 -	-e "s/^DefStandardHeap\(\W\)/SetStandradHeap\1/g"\
    1.76 -	-e "s/^DefStandardHeap$/SetStandradHeap/g"\
    1.77 -	-e "s/\(\W\)DefOperationTraits\(\W\)/\1SetOperationTraits\2/g"\
    1.78 -	-e "s/\(\W\)DefOperationTraits$/\1SetOperationTraits/g"\
    1.79 -	-e "s/^DefOperationTraits\(\W\)/SetOperationTraits\1/g"\
    1.80 -	-e "s/^DefOperationTraits$/SetOperationTraits/g"\
    1.81 -	-e "s/\(\W\)DefProcessedMapToBeDefaultMap\(\W\)/\1SetStandardProcessedMap\2/g"\
    1.82 -	-e "s/\(\W\)DefProcessedMapToBeDefaultMap$/\1SetStandardProcessedMap/g"\
    1.83 -	-e "s/^DefProcessedMapToBeDefaultMap\(\W\)/SetStandardProcessedMap\1/g"\
    1.84 -	-e "s/^DefProcessedMapToBeDefaultMap$/SetStandardProcessedMap/g"\
    1.85 -	-e "s/\(\W\)IntegerMap\(\W\)/\1RangeMap\2/g"\
    1.86 -	-e "s/\(\W\)IntegerMap$/\1RangeMap/g"\
    1.87 -	-e "s/^IntegerMap\(\W\)/RangeMap\1/g"\
    1.88 -	-e "s/^IntegerMap$/RangeMap/g"\
    1.89 -	-e "s/\(\W\)integerMap\(\W\)/\1rangeMap\2/g"\
    1.90 -	-e "s/\(\W\)integerMap$/\1rangeMap/g"\
    1.91 -	-e "s/^integerMap\(\W\)/rangeMap\1/g"\
    1.92 -	-e "s/^integerMap$/rangeMap/g"\
    1.93 -	-e "s/\(\W\)copyGraph\(\W\)/\1graphCopy\2/g"\
    1.94 -	-e "s/\(\W\)copyGraph$/\1graphCopy/g"\
    1.95 -	-e "s/^copyGraph\(\W\)/graphCopy\1/g"\
    1.96 -	-e "s/^copyGraph$/graphCopy/g"\
    1.97 -	-e "s/\(\W\)copyDigraph\(\W\)/\1digraphCopy\2/g"\
    1.98 -	-e "s/\(\W\)copyDigraph$/\1digraphCopy/g"\
    1.99 -	-e "s/^copyDigraph\(\W\)/digraphCopy\1/g"\
   1.100 -	-e "s/^copyDigraph$/digraphCopy/g"\
   1.101 -	-e "s/\(\W\)\([sS]\)tdMap\(\W\)/\1\2parseMap\3/g"\
   1.102 -	-e "s/\(\W\)\([sS]\)tdMap$/\1\2parseMap/g"\
   1.103 -	-e "s/^\([sS]\)tdMap\(\W\)/\1parseMap\2/g"\
   1.104 -	-e "s/^\([sS]\)tdMap$/\1parseMap/g"\
   1.105 -	-e "s/\(\W\)\([Ff]\)unctorMap\(\W\)/\1\2unctorToMap\3/g"\
   1.106 -	-e "s/\(\W\)\([Ff]\)unctorMap$/\1\2unctorToMap/g"\
   1.107 -	-e "s/^\([Ff]\)unctorMap\(\W\)/\1unctorToMap\2/g"\
   1.108 -	-e "s/^\([Ff]\)unctorMap$/\1unctorToMap/g"\
   1.109 -	-e "s/\(\W\)\([Mm]\)apFunctor\(\W\)/\1\2apToFunctor\3/g"\
   1.110 -	-e "s/\(\W\)\([Mm]\)apFunctor$/\1\2apToFunctor/g"\
   1.111 -	-e "s/^\([Mm]\)apFunctor\(\W\)/\1apToFunctor\2/g"\
   1.112 -	-e "s/^\([Mm]\)apFunctor$/\1apToFunctor/g"\
   1.113 -	-e "s/\(\W\)\([Ff]\)orkWriteMap\(\W\)/\1\2orkMap\3/g"\
   1.114 -	-e "s/\(\W\)\([Ff]\)orkWriteMap$/\1\2orkMap/g"\
   1.115 -	-e "s/^\([Ff]\)orkWriteMap\(\W\)/\1orkMap\2/g"\
   1.116 -	-e "s/^\([Ff]\)orkWriteMap$/\1orkMap/g"\
   1.117 -	-e "s/\(\W\)StoreBoolMap\(\W\)/\1LoggerBoolMap\2/g"\
   1.118 -	-e "s/\(\W\)StoreBoolMap$/\1LoggerBoolMap/g"\
   1.119 -	-e "s/^StoreBoolMap\(\W\)/LoggerBoolMap\1/g"\
   1.120 -	-e "s/^StoreBoolMap$/LoggerBoolMap/g"\
   1.121 -	-e "s/\(\W\)storeBoolMap\(\W\)/\1loggerBoolMap\2/g"\
   1.122 -	-e "s/\(\W\)storeBoolMap$/\1loggerBoolMap/g"\
   1.123 -	-e "s/^storeBoolMap\(\W\)/loggerBoolMap\1/g"\
   1.124 -	-e "s/^storeBoolMap$/loggerBoolMap/g"\
   1.125 -	-e "s/\(\W\)BoundingBox\(\W\)/\1Box\2/g"\
   1.126 -	-e "s/\(\W\)BoundingBox$/\1Box/g"\
   1.127 -	-e "s/^BoundingBox\(\W\)/Box\1/g"\
   1.128 -	-e "s/^BoundingBox$/Box/g"\
   1.129 -<$1 > $TMP
   1.130 -
   1.131 -mv $TMP $1
   1.132 \ No newline at end of file
   1.133 +for i in $@
   1.134 +do
   1.135 +    echo Update $i...
   1.136 +    TMP=`mktemp`
   1.137 +    sed -e "s/undirected graph/_gr_aph_label_/g"\
   1.138 +        -e "s/undirected edge/_ed_ge_label_/g"\
   1.139 +        -e "s/graph_/_gr_aph_label__/g"\
   1.140 +        -e "s/_graph/__gr_aph_label_/g"\
   1.141 +        -e "s/UGraph/_Gr_aph_label_/g"\
   1.142 +        -e "s/uGraph/_gr_aph_label_/g"\
   1.143 +        -e "s/ugraph/_gr_aph_label_/g"\
   1.144 +        -e "s/Graph/_Digr_aph_label_/g"\
   1.145 +        -e "s/graph/_digr_aph_label_/g"\
   1.146 +        -e "s/UEdge/_Ed_ge_label_/g"\
   1.147 +        -e "s/uEdge/_ed_ge_label_/g"\
   1.148 +        -e "s/uedge/_ed_ge_label_/g"\
   1.149 +        -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\
   1.150 +        -e "s/Edge/_Ar_c_label_/g"\
   1.151 +        -e "s/edge/_ar_c_label_/g"\
   1.152 +        -e "s/ANode/_Re_d_label_/g"\
   1.153 +        -e "s/BNode/_Blu_e_label_/g"\
   1.154 +        -e "s/A-Node/_Re_d_label_/g"\
   1.155 +        -e "s/B-Node/_Blu_e_label_/g"\
   1.156 +        -e "s/anode/_re_d_label_/g"\
   1.157 +        -e "s/bnode/_blu_e_label_/g"\
   1.158 +        -e "s/aNode/_re_d_label_/g"\
   1.159 +        -e "s/bNode/_blu_e_label_/g"\
   1.160 +        -e "s/_Digr_aph_label_/Digraph/g"\
   1.161 +        -e "s/_digr_aph_label_/digraph/g"\
   1.162 +        -e "s/_Gr_aph_label_/Graph/g"\
   1.163 +        -e "s/_gr_aph_label_/graph/g"\
   1.164 +        -e "s/_Ar_c_label_/Arc/g"\
   1.165 +        -e "s/_ar_c_label_/arc/g"\
   1.166 +        -e "s/_Ed_ge_label_/Edge/g"\
   1.167 +        -e "s/_ed_ge_label_/edge/g"\
   1.168 +        -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
   1.169 +        -e "s/_Re_d_label_/Red/g"\
   1.170 +        -e "s/_Blu_e_label_/Blue/g"\
   1.171 +        -e "s/_re_d_label_/red/g"\
   1.172 +        -e "s/_blu_e_label_/blue/g"\
   1.173 +        -e "s/\<DefPredMap\>/SetPredMap/g"\
   1.174 +        -e "s/\<DefDistMap\>/SetDistMap/g"\
   1.175 +        -e "s/\<DefReachedMap\>/SetReachedMap/g"\
   1.176 +        -e "s/\<DefProcessedMap\>/SetProcessedMap/g"\
   1.177 +        -e "s/\<DefHeap\>/SetHeap/g"\
   1.178 +        -e "s/\<DefStandardHeap\>/SetStandradHeap/g"\
   1.179 +        -e "s/\<DefOperationTraits\>/SetOperationTraits/g"\
   1.180 +        -e "s/\<DefProcessedMapToBeDefaultMap\>/SetStandardProcessedMap/g"\
   1.181 +        -e "s/\<copyGraph\>/graphCopy/g"\
   1.182 +        -e "s/\<copyDigraph\>/digraphCopy/g"\
   1.183 +        -e "s/\<IntegerMap\>/RangeMap/g"\
   1.184 +        -e "s/\<integerMap\>/rangeMap/g"\
   1.185 +        -e "s/\<\([sS]\)tdMap\>/\1parseMap/g"\
   1.186 +        -e "s/\<\([Ff]\)unctorMap\>/\1unctorToMap/g"\
   1.187 +        -e "s/\<\([Mm]\)apFunctor\>/\1apToFunctor/g"\
   1.188 +        -e "s/\<\([Ff]\)orkWriteMap\>/\1orkMap/g"\
   1.189 +        -e "s/\<StoreBoolMap\>/LoggerBoolMap/g"\
   1.190 +        -e "s/\<storeBoolMap\>/loggerBoolMap/g"\
   1.191 +        -e "s/\<BoundingBox\>/Box/g"\
   1.192 +    <$i > $TMP
   1.193 +    mv $TMP $i
   1.194 +done