|
Mon Oct 15 20:59:45 EDT 2007
Perl FLaT Updates
--
It's been a while since I've provided an update on Perl FLaT, but
I recently implemented "string" pumping. As I move towards a
"1.0" release, I am still aiming to implemented a DFA to Regular
Expression conversion feature.
I also updated the website/wiki to be a bit more tidy. I've
added information on the string pumping thing, to.
Links:
See FLaT Wiki
Wiki page on string generation
Below is an example of the sort of Perl one may use to generate
valid strings given a regular expression. It requires converting
a regular expression to a DFA, but that's what FLaT is all about
:)
#!/usr/bin/env perl
use strict;
use warnings;
use FLAT::DFA;
use FLAT::NFA;
use FLAT::PFA;
use FLAT::Regex::WithExtraOps;
my $PRE = "abc&(def)*";
my $dfa = FLAT::Regex::WithExtraOps->new($PRE)->as_pfa->as_nfa->as_dfa
+->as_min_dfa->trim_sinks;
my $next = $dfa->new_acyclic_string_generator;
print "PRE: $PRE0;
print "Acyclic:0;
while (my $string = $next->()) {
print " $string0;
}
$next = $dfa->new_deepdft_string_generator();
print "Deep DFT (default):0;
for (1..10) {
while (my $string = $next->()) {
print " $string0;
last;
}
}
$next = $dfa->new_deepdft_string_generator(5);
print "Deep DFT (5):0;
for (1..10) {
while (my $string = $next->()) {
print " $string0;
last;
}
}
will yield:
PRE: abc&(def)*
Acyclic:
deabfc
deabcf
dabcef
dabefc
dabecf
daebfc
daebcf
abc
adbcef
adbefc
adbecf
adebfc
adebcf
Deep DFT (default):
deabfdcef
deabfc
deabcf
deafbdcef
deafbdecf
deafbc
deafdbcef
deafdbefc
deafdbecf
dabcef
Deep DFT (5):
defdefdefdefdeabfdcef
defdefdefdefdeabfdcefdef
defdefdefdefdeabfdcefdefdef
defdefdefdefdeabfdcefdefdefdef
defdefdefdefdeabfdcefdefdefdefdef
defdefdefdefdeabfdefdcef
defdefdefdefdeabfdefdcefdef
defdefdefdefdeabfdefdcefdefdef
defdefdefdefdeabfdefdcefdefdefdef
defdefdefdefdeabfdefdcefdefdefdefdef
I am writing up some info on the recursively generator iterators
technique that I utilized to create the valid string iterator on
PerlMonks soon, and I will update this post with a link as soon
as it is done.
Enjoy!
--
Powered by vee Copyright © 2006-2008
|
|