From: notifies s. of c. c. <per...@li...> - 2006-09-27 03:38:22
|
Revision: 74 http://svn.sourceforge.net/perl-flat/?rev=74&view=rev Author: estrabd Date: 2006-09-26 20:38:17 -0700 (Tue, 26 Sep 2006) Log Message: ----------- added NFA->as_gdl, which outputs to the graph description language; sub routine basically identical to as_graphviz, but with different formatting Modified Paths: -------------- trunk/perl-flat/TODO trunk/perl-flat/dev-scripts/pregex-to-pfa.pl trunk/perl-flat/lib/FLAT/NFA.pm trunk/perl-flat/lib/FLAT/PFA.pm Modified: trunk/perl-flat/TODO =================================================================== --- trunk/perl-flat/TODO 2006-09-26 23:27:06 UTC (rev 73) +++ trunk/perl-flat/TODO 2006-09-27 03:38:17 UTC (rev 74) @@ -10,4 +10,4 @@ input and output options and formats - +look at creating a 'drop in' regex/pregex parser using the custom recdesc one build for FLAT::Legacy Modified: trunk/perl-flat/dev-scripts/pregex-to-pfa.pl =================================================================== --- trunk/perl-flat/dev-scripts/pregex-to-pfa.pl 2006-09-26 23:27:06 UTC (rev 73) +++ trunk/perl-flat/dev-scripts/pregex-to-pfa.pl 2006-09-27 03:38:17 UTC (rev 74) @@ -11,10 +11,11 @@ my $PFA = $PRE->as_pfa(); +my $gdl = $PFA->as_gdl; my $graphviz = $PFA->as_graphviz; my $summary = $PFA->as_summary; -print "$summary\n"; +print "$gdl\n"; open my $fh, "|-", "circo -Tpng -o output.png" or die "Couldn't run graphviz: $!\n"; Modified: trunk/perl-flat/lib/FLAT/NFA.pm =================================================================== --- trunk/perl-flat/lib/FLAT/NFA.pm 2006-09-26 23:27:06 UTC (rev 73) +++ trunk/perl-flat/lib/FLAT/NFA.pm 2006-09-27 03:38:17 UTC (rev 74) @@ -222,8 +222,36 @@ $self->add_transition($trash, $trash, $self->alphabet); } -############ +############ Formatted output + +# Graph Description Language, aiSee, etc +sub as_gdl { + my $self = shift; + + my @states = map { + sprintf qq{node: { title:"%s" shape:circle borderstyle: %s}\n}, + $_, + ($self->is_accepting($_) ? "double bordercolor: red" : "solid") + } $self->get_states; + + my @trans; + for my $s1 ($self->get_states) { + for my $s2 ($self->get_states) { + my $t = $self->get_transition($s1, $s2); + + if (defined $t) { + push @trans, sprintf qq[edge: { source: "%s" target: "%s" label: "%s" arrowstyle: line }\n], + $s1, $s2, $t->as_string; + } + }} + + return sprintf "graph: {\ndisplay_edge_labels: yes\n\n%s\n%s}\n", + join("", @states), + join("", @trans); +} + +# Graphviz: dot, etc sub as_graphviz { my $self = shift; Modified: trunk/perl-flat/lib/FLAT/PFA.pm =================================================================== --- trunk/perl-flat/lib/FLAT/PFA.pm 2006-09-26 23:27:06 UTC (rev 73) +++ trunk/perl-flat/lib/FLAT/PFA.pm 2006-09-27 03:38:17 UTC (rev 74) @@ -193,8 +193,9 @@ # } #1. make sure psuedo code is correct -#2. implement it, including any require initializations -#3. refine, refactor +#2 translate using the current PFA data structure +#3. implement it, including any require initializations +#4. refine, refactor sub as_nfa { my $self = shift; @@ -202,7 +203,7 @@ my %Dtran =(); # hash of serialized state names that have been searched # New NFA object reference my $result = FLAT::NFA->new(); - + return $result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |