#!/usr/bin/perl ($noOfStates,$noOfSymbols,$noOfFinalStates) = split (" ",); print STDERR "#States = $noOfStates, #Symbols = $noOfSymbols, #Final States = $noOfFinalStates\n"; @finalStates = split (" ",); print STDERR "Final States {@finalStates}\n"; print "digraph DFA{\n"; print "\tnode [shape=circle];\n"; for (@finalStates) { print "$_ [label=\"$_(F)\" style=bold];\n"; } @noOfTransitions; while (){ ($from,$symbol,$to) = split " "; if(ord ($symbol)< ord("a") + $noOfSymbols && $from < $noOfStates && $to < $noOfStates){ print "$from -> $to [label=\"$symbol\"];\n"; $noOfTransitions[$from]++; }else{ print STDERR "Invalid Transition : $_"; } } print "}\n"; $stateNo = 0; for (@noOfTransitions) { if($_ != $noOfSymbols){ print STDERR "No of Transitions from State $stateNo is $_ !\n"; } $stateNo++; } if($stateNo != $noOfStates){ print STDERR "Trasitions are defined (only) on $stateNo States !!\n"; }