#! /usr/bin/perl
use strict;
use warnings;
use MorfEnc;

my $maxunival = 0;

my (@cp2morf, @morf2cp);


for my $name (sort keys %morfenc) {

(print STDERR "? $name \n"), next
    unless $name =~ /^0x([0-9a-fA-F]{4})\t(.+)$/;

my $code = hex($1);
my $mcode = $morfenc{$name};
if (!defined($mcode)) {
    print STDERR "UNK: $name\n";
    next;
}

$maxunival = $code if $code > $maxunival;

$cp2morf[$code]=$mcode;
$morf2cp[$mcode]=$code unless defined($morf2cp[$mcode]);

}

# for (my $i=0; $i<$maxunival; $i++) {
#     $cp2morf[$i]=$morfenc{'NOTACHARACTER'};
# #    $morf2cp[$i]=256;
# }

print STDERR "MAXUNIVAL: $maxunival\n";


print "\$CASEABLE = $morfenc{'CASEABLE'};\n\n";
print "\@unicode_morf = (\n";
print join ', ', map {defined($_)?$_:'undef'} @cp2morf;
print ");\n";

