]> jfr.im git - irc/SurrealServices/srsv.git/blob - branches/erry-devel/parse-msg_h.pl
initial commit of erry's Insp work.
[irc/SurrealServices/srsv.git] / branches / erry-devel / parse-msg_h.pl
1 #!/usr/bin/perl
2
3 use strict;
4
5 my (%cmd_hash, %tok_hash);
6 my $debug = 0;
7
8 #open MSGH, "include/msg.h";
9 while (my $l = <STDIN>) {
10 chomp $l;
11 if ($l =~ /^#define(\s|\t)MSG_(\w+)(\s|\t)+\"(\S+)\".*/) {
12 $cmd_hash{$2}->{MSG} = $4;
13 print $l."\n" if $debug;
14 print "$2 $4"."\n" if $debug;
15 }
16 elsif ($l =~ /^#define(\s|\t)TOK_(\w+)(\s|\t)+\"(\S+)\".*/) {
17 $cmd_hash{$2}->{TOK} = $4;
18 print $l."\n" if $debug;
19 print "$2 $4"."\n" if $debug;
20 }
21 }
22 #close MSGH;
23
24
25 foreach my $key (keys(%cmd_hash)) {
26 my $tok = $cmd_hash{$key}{TOK};
27 my $msg = $cmd_hash{$key}{MSG};
28 # print $msg.' 'x(12-length($msg)). $tok."\n" if ($msg and $tok);
29 $tok_hash{$tok} = $msg if ($msg and $tok);
30 }
31
32 for(my $l = 1; $l <= 2; $l++) {
33 foreach my $key (sort keys %tok_hash) {
34 print $tok_hash{$key}.' 'x(12-length($tok_hash{$key})). $key."\n" if length($key) == $l;
35 }
36 }