#!/local/bin/perl open(I,"cgram.h"); while(){ chomp; $num=""; ($name,$num)=m/#define\s+(\w+)\s+(\d+)/; next if ($num eq ""); @names[$num]=$name; } close(I); print "static char * tokens[] = {\n"; $i=0; while ($i <= $#names){ if(@names[$i] eq ""){ print " \"undefined#$i\",\n"; } else { print " \"@names[$i]\",\n"; } $i++; } print " 0};\n";