Mercurial > hg > CbC > old > device
view tools/mc-h-renum.pl @ 912:553cd297b0a8
empty struct initialization in decl (finally) in non parse mode
author | kono |
---|---|
date | Wed, 09 Apr 2014 21:21:26 +0900 |
parents | e055df7c1082 |
children |
line wrap: on
line source
#!/usr/local/bin/perl # /************************************************************************ # ** Copyright (C) 2006 Shinji Kono # ** 連絡先: 琉球大学情報工学科 河野 真治 # ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp) # ** # ** このソースのいかなる複写,改変,修正も許諾します。ただし、 # ** その際には、誰が貢献したを示すこの部分を残すこと。 # ** 再配布や雑誌の付録などの問い合わせも必要ありません。 # ** 営利利用も上記に反しない範囲で許可します。 # ** バイナリの配布の際にはversion messageを保存することを条件とします。 # ** このプログラムについては特に何の保証もしない、悪しからず。 # ** # ** Everyone is permitted to do anything on this program # ** including copying, modifying, improving, # ** as long as you don't try to pretend that you wrote it. # ** i.e., the above copyright notice has to appear in all copies. # ** Binary distribution requires original version messages. # ** You don't have to ask before copying, redistribution or publishing. # ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. # ***********************************************************************/ my $mode = 0; my $reserve = -1; my $tags = 1; my $error = 1; my $modnum = 0; while(<>) { if(m+/\* reserved word start \*/+) { $mode = 1; } elsif(m+/\* reserved word end \*/+) { $mode = 0; } elsif(m+/\* tree node tags start \*/+) { $mode = 2; } elsif(m+/\* tree node tags end \*/+) { $mode = 0; } elsif(m+/\* error number start \*/+) { $mode = 3; } elsif(m+/\* error number end \*/+) { $mode = 0; } elsif(m+/\* mode start \*/+) { $mode = 4; } elsif(m+/\* mode end \*/+) { $mode = 0; } elsif(m+/\* statement start \*/+) { $mode = 5; } elsif(m+/\* statement end \*/+) { $mode = 0; } else { if ($mode==0) { ; } elsif ($mode==1) { s/-(\d+)/$reserve--/e; } elsif ($mode==2) { s/\s(\d+)/"\t".$tags++/e; } elsif ($mode==3) { s/(\d+)/$error++/e; } elsif ($mode==4) { s/(\d+)/$modenum++/e; } elsif ($mode==5) { s/(\d+)/$tags++/e; } } print; }