|
From: notifies s. of c. c. <per...@li...> - 2007-02-16 19:59:25
|
Revision: 94
http://svn.sourceforge.net/perl-flat/?rev=94&view=rev
Author: estrabd
Date: 2007-02-16 11:59:22 -0800 (Fri, 16 Feb 2007)
Log Message:
-----------
committing, but think I found a weird bug
Modified Paths:
--------------
trunk/perl-flat/dev-scripts/bdetest.pl
trunk/perl-flat/lib/FLAT/NFA.pm
trunk/perl-flat/lib/FLAT.pm
Modified: trunk/perl-flat/dev-scripts/bdetest.pl
===================================================================
--- trunk/perl-flat/dev-scripts/bdetest.pl 2007-02-15 17:54:42 UTC (rev 93)
+++ trunk/perl-flat/dev-scripts/bdetest.pl 2007-02-16 19:59:22 UTC (rev 94)
@@ -2,8 +2,6 @@
use strict;
use lib qw(../lib);
-use FLAT::Regex::Transform;
-use Data::Dumper;
+use FLAT::Regex::WithExtraOps;
-my $trans = FLAT::Regex::Transform->new('abc&efg+hi');
-print Dumper($trans);
+print FLAT::Regex->new('a')->as_nfa->as_dfa->as_min_dfa->as_undirected;
Modified: trunk/perl-flat/lib/FLAT/NFA.pm
===================================================================
--- trunk/perl-flat/lib/FLAT/NFA.pm 2007-02-15 17:54:42 UTC (rev 93)
+++ trunk/perl-flat/lib/FLAT/NFA.pm 2007-02-16 19:59:22 UTC (rev 94)
@@ -207,7 +207,54 @@
############ Formatted output
+# Format that Dr. Sukhamay KUNDU likes to use in his assignments :)
+# This format is just a undirected graph - so transition and state info is lost
+sub as_undirected {
+ my $self = shift;
+ my @symbols = $self->alphabet();
+ my @states = $self->get_states();
+ my @lines = ();
+ foreach (@states) {
+ my $s = $_;
+ my @conns = ();
+ foreach (@symbols) {
+ my $a = $_;
+ # foreach state, get all nodes connected to it; ignore symbols and
+ # treat transitions simply as directed
+ push(@conns,$self->successors($s,$a));
+ push(@conns,$self->predecessors($s,$a)); #<-- something terribly wrong is going on here
+ }
+ @conns = $self->array_unique(@conns);
+ push(@lines,sprintf("%s (%s) %s",$s,($#conns+1),join(' ',@conns)));
+ }
+ return sprintf("%s\n%s",($#states+1),join("\n",@lines));
+}
+
+# Format that Dr. Sukhamay KUNDU likes to use in his assignments :)
+# This format is just a directed graph - so transition and state info is lost
+
+sub as_directed {
+ my $self = shift;
+ my @symbols = $self->alphabet();
+ my @states = $self->get_states();
+ my @lines = ();
+ foreach (@states) {
+ my $s = $_;
+ my @conns = ();
+ foreach (@symbols) {
+ my $a = $_;
+ # foreach state, get all nodes connected to it; ignore symbols and
+ # treat transitions simply as directed
+ push(@conns,$self->successors($s,$a));
+ }
+ @conns = $self->array_unique(@conns);
+ push(@lines,sprintf("%s (%s) %s",$s,($#conns+1),join(' ',@conns)));
+ }
+ return sprintf("%s\n%s",($#states+1),join("\n",@lines));
+}
+
+
# Graph Description Language, aiSee, etc
sub as_gdl {
my $self = shift;
Modified: trunk/perl-flat/lib/FLAT.pm
===================================================================
--- trunk/perl-flat/lib/FLAT.pm 2007-02-15 17:54:42 UTC (rev 93)
+++ trunk/perl-flat/lib/FLAT.pm 2007-02-16 19:59:22 UTC (rev 94)
@@ -64,9 +64,12 @@
@EXPORT = qw(compare
dump
- dfa2dot
- nfa2dot
- pfa2dot
+ dfa2gv
+ nfa2gv
+ pfa2gv
+ dfa2directed
+ nfa2directed
+ pfa2directed
random_pre
random_re
help
@@ -106,9 +109,15 @@
%perl -MFLAT -e
"compare 're1','re2'" # comares 2 regexs | see note [2]
"dump 're1'" # dumps parse trees | see note[1]
- "dfa2dot 're1'" # dumps graphviz graph desc | see note[1]
- "nfa2dot 're1'" # dumps graphviz graph desc | see note[1]
- "pfa2dot 're1'" # dumps graphviz graph desc | see note[1]
+ "dfa2gv 're1'" # dumps graphviz graph desc | see note[1]
+ "nfa2gv 're1'" # dumps graphviz graph desc | see note[1]
+ "pfa2gv 're1'" # dumps graphviz graph desc | see note[1]
+ dfa2directed
+ nfa2directed
+ pfa2directed
+ dfa2undirected
+ nfa2undirected
+ pfa2undirected
random_pre
random_re
help
@@ -176,8 +185,8 @@
# dumps graphviz notation
# Usage:
-# perl -MFLAT -e "dfa2dot('a&b&c&d*e*')"
-sub dfa2dot {
+# perl -MFLAT -e "dfa2gv('a&b&c&d*e*')"
+sub dfa2gv {
shift;
use FLAT::Regex::WithExtraOps;
use FLAT::DFA;
@@ -197,8 +206,8 @@
# dumps graphviz notation
# Usage:
-# perl -MFLAT -e "nfa2dot('a&b&c&d*e*')"
-sub nfa2dot {
+# perl -MFLAT -e "nfa2gv('a&b&c&d*e*')"
+sub nfa2gv {
shift;
use FLAT::Regex::WithExtraOps;
use FLAT::DFA;
@@ -218,8 +227,8 @@
# dumps graphviz notation
# Usage:
-# perl -MFLAT -e "pfa2dot('a&b&c&d*e*')"
-sub pfa2dot {
+# perl -MFLAT -e "pfa2gv('a&b&c&d*e*')"
+sub pfa2gv {
shift;
use FLAT::Regex::WithExtraOps;
use FLAT::PFA;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|