view mc-h-renum.pl @ 436:d92786033042 loprtc-div

loprtc
author kono
date Sun, 14 Nov 2004 15:41:05 +0900
parents 3902240d4930
children 1e5ca85d3f97
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; }
    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;
	}
    }
    print;
}