mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
add -raw option to dump DAWG in way useful for debugging engine and
dawgshow.
This commit is contained in:
parent
807201ec62
commit
eb168cf1f2
1 changed files with 35 additions and 5 deletions
|
@ -24,12 +24,14 @@ use strict;
|
||||||
use Fcntl;
|
use Fcntl;
|
||||||
|
|
||||||
my $gInFile;
|
my $gInFile;
|
||||||
|
my $gDoRaw = 0;
|
||||||
my $gFileType;
|
my $gFileType;
|
||||||
my $gNodeSize;
|
my $gNodeSize;
|
||||||
|
|
||||||
sub usage() {
|
sub usage() {
|
||||||
print STDERR "USAGE: $0 "
|
print STDERR "USAGE: $0 "
|
||||||
. "<xwdORpdb>"
|
. "[-raw] "
|
||||||
|
. "-dict <xwdORpdb>"
|
||||||
. "\n"
|
. "\n"
|
||||||
. "\t(Takes a .pdb or .xwd and prints its words to stdout)\n";
|
. "\t(Takes a .pdb or .xwd and prints its words to stdout)\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
|
@ -37,9 +39,14 @@ sub usage() {
|
||||||
|
|
||||||
sub parseARGV() {
|
sub parseARGV() {
|
||||||
|
|
||||||
$gInFile = shift(@ARGV);
|
while ( my $parm = shift(@ARGV) ) {
|
||||||
if ( 0 != @ARGV ) {
|
if ( $parm eq "-raw" ) {
|
||||||
usage();
|
$gDoRaw = 1;
|
||||||
|
} elsif ( $parm eq "-dict" ) {
|
||||||
|
$gInFile = shift(@ARGV);
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $gInFile =~ m|.xwd$| ) {
|
if ( $gInFile =~ m|.xwd$| ) {
|
||||||
|
@ -311,6 +318,25 @@ sub printDAWG($$$$) {
|
||||||
}
|
}
|
||||||
} # printDAWG
|
} # printDAWG
|
||||||
|
|
||||||
|
sub printNodes($$) {
|
||||||
|
my ( $nr, $fr ) = @_;
|
||||||
|
|
||||||
|
my $len = @$nr;
|
||||||
|
for ( my $i = 0; $i < $len; ++$i ) {
|
||||||
|
my $node = $$nr[$i];
|
||||||
|
|
||||||
|
my ( $chrIndex, $nextEdge, $accepting, $lastEdge );
|
||||||
|
parseNode( $node, \$chrIndex, \$nextEdge, \$accepting, \$lastEdge );
|
||||||
|
|
||||||
|
printf "%.8x: (%.8x) %2d(%s) %.8x ", $i, $node, $chrIndex,
|
||||||
|
$$fr[$chrIndex], $nextEdge;
|
||||||
|
print ($accepting? "A":"a");
|
||||||
|
print " ";
|
||||||
|
print ($lastEdge? "L":"l");
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
# main
|
# main
|
||||||
#################################################################
|
#################################################################
|
||||||
|
@ -333,6 +359,10 @@ if ( $gFileType eq "xwd" ){
|
||||||
close INFILE;
|
close INFILE;
|
||||||
|
|
||||||
die "no nodes!!!" if 0 == @nodes;
|
die "no nodes!!!" if 0 == @nodes;
|
||||||
printDAWG( [], \@nodes, $startIndex, \@faces );
|
if ( $gDoRaw ) {
|
||||||
|
printNodes( \@nodes, \@faces );
|
||||||
|
} else {
|
||||||
|
printDAWG( [], \@nodes, $startIndex, \@faces );
|
||||||
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue