#!/usr/bin/perl # # Alex Linke # # A short introduction on the filter's usage can be found here: # http://www.use-strict.de/software/fst2dot.html # The filter's license is available here: # http://www.use-strict.de/files/software/LICENSE.txt # There's no warranty at all - Use at own risk! use strict; die "usage: $0 [file|-]\n" if (@ARGV != 1); my $input = $ARGV[0]; $input = '/dev/stdin' if $input eq '-'; open FH, $input or die "Cannot open file '$input':\n\t$!\n"; my @dotfile; push @dotfile, "# automatically generated by $0\n" . "digraph agraph {\n\tnode [shape=\"circle\",label=\"\"];\n"; foreach(){ chomp; if (/^(\d+)\t([^\t]+)\t(\d+)$/) { push @dotfile, "\n\t$1 -> $3 [label=\"$2\"];"; } elsif (/^final: (\d+)$/) { push @dotfile, "\n\t$1 [shape=\"doublecircle\"]"; } else { print STDERR "error parsing line: '$_'\n"; exit 1; } } print @dotfile, "\n}\n";