view tools/mc-h-renum.pl @ 550:df60b120675d

*** empty log message ***
author kono
date Tue, 03 Jan 2006 22:23:26 +0900
parents 7c3d8237b625
children e055df7c1082
line wrap: on
line source

#!/usr/local/bin/perl

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;
}