1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-17 00:53:09 +02:00
eda-tools/old-boom/gen2chr

65 lines
963 B
Plaintext
Raw Normal View History

2012-05-02 05:09:24 +03:00
#!/usr/bin/perl
require "parser.pl";
require "match.pl";
sub translate
{
local ($r) = @_;
undef %field;
$field{"REF"} = $r;
&match_set_error($r);
if (!&apply_rules()) {
print "$id{$r}\n" if $negate;
return;
}
return if $negate;
print $id{$r};
for (sort keys %field) {
next if $_ =~ /^_/;
next if $_ eq "REF";
print " $_=$field{$_}";
}
print "\n";
}
sub usage
{
print STDERR "usage: $0 [-d|-n] key file ...\n";
print STDERR " $0 -q query file ...\n";
exit(1);
}
while ($ARGV[0] =~ /^-/) {
if ($ARGV[0] eq "-d") {
$debug = 1;
} elsif ($ARGV[0] eq "-n") {
$negate = 1;
} elsif ($ARGV[0] eq "-q") {
$query = 1;
} else {
&usage;
}
shift @ARGV;
}
$key = shift @ARGV;
&usage unless defined $key;
&parse;
if ($query) {
$debug = 1;
&translate($key);
exit(0);
}
print "#CHR\n";
for (keys %id) {
next unless $id{$_} eq "$key $_";
&translate($_);
}