#!/usr/bin/perl
# -*- perl -*-

$stage = 1;			       
while(<>)			
{				
    if (/^#/){
	next;
    }
    if ($stage == 2)
    {
	chop;
	/[ \t]*([^ \t]*)[ \t]*([^ \t]*)/;
	$dd = "";
	for($i=0;$i<length($1);$i++)
	{
	    if (substr($1,$i,1) eq '\\')
	    {
		$dd .= sprintf("%c",oct(substr($1,$i+1,3)));
		$i+=3;
	    }
	    else
	    {
		$dd .= substr($1,$i,1);
	    }
	}
	for($i=0;$i < length($2);$i+=2)
	{
	    if ($i +1 >= length($2))
	    {
		last;
	    }
	    $tt = substr($2,$[+$i,2);
	    	
	    print "$dd $tt\n";
	}
	next;	
    }
	
    if ( /^PROMPT:[ \t]*[^ \t]*::([^ \t]*)::/){
	$tt = substr($1,length($1)-2,2);
	print "MARK [$tt]\n";
	print "bell\n";
	print "%%\n";
    }
    if (/^KEYPROMPT\(([^)]*)\):[ \t]*([^ \n\t]*)/) {
	$tt = $1;
	if (substr($tt,0,1) eq '\\') 
	{
	    $ccc = oct(substr($tt,1));
	    $ccc = sprintf("%c",$ccc);
	}
	else
	{
	    $ccc = $tt;
	}			
	print "$ccc $2\n";
    }
    if (/BEGINDICTIONARY/)
    {
	$stage = 2;
	print "%%\n";
    }
}
	
print STDERR "This script is still in testing,you should check the result\n";
print STDERR "file and make some wrong in it.\n";	    
				
				

				

	
	
	
	
	
    
