- $mnem =~ s{<([^>]+)> \h?}{$symname->{$1} // die "reference to unknown keysym $1\n"}eg;
- $mnem !~ m/[^\x20-\x7F]/ or next; # skip unicode
-# (state $seen = {})->{$chr}++ and next;
- printf "%s => %s,\n", pp($mnem), pp($chr);
+ eval {
+ $mnem =~ s{<([^>]+)> \h?}{$symname->{$1} // die "reference to unknown keysym $1\n"}eg;
+ 1;
+ } or warn($@), next;
+ $mnem =~ m/\A [\x20-\x7F]{2} \z/ or next; # only interested in two ascii
+
+ my $alias = \(state $seen = {})->{$chr}; # assume first is preferred
+ my $cp = ord $chr;
+ my ($class, $name, undef, undef, $string) = @{
+ Shiar_Sheet::FormatChar->glyph_info($cp)
+ };
+ my $comparison = (
+ !$vidi->{key}->{$mnem} ? 'l3' : # free
+ $vidi->{key}->{$mnem}->[0] != $cp ? 'l1' : # conflict
+ $vidi->{key}->{$mnem}->[2] eq 'l5' ? 'l5' : # rfc
+ 'l4' # any
+ );
+
+ if (${$alias}) {
+ # aliases an earlier occurrence
+ if ($matchvim and ${$alias}->[2] lt $comparison) {
+ # replace lower compatibility level
+ ${$alias}->[3] = 'l0';
+ ${$alias}->[2] .= ' u-' . ${$alias}->[2];
+ ${$alias} = undef;
+ }
+ else {
+ $class = 'l0';
+ my $menm = substr($mnem, 1, 1).substr($mnem, 0, 1);
+ if ($table{$menm} && $table{$menm}[0] == $cp) {
+ # unannotated if identical to reversed input
+ $cp = 0;
+ }
+ else {
+ $class .= ' ex';
+ }
+ }
+ }
+
+ $table{$mnem} = [ $cp, $name, $comparison, $class, $string // () ];
+ ${$alias} //= $table{$mnem};