This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: expect module


Gary Houston <ghouston@easynet.co.uk> writes:

> | Gary Houston <ghouston@easynet.co.uk>
> | > True.  I had a vague idea of rewriting part of it in C.  Adding a
> | > per-line mode may be a good idea too.  Perhaps implementing
> | > expect-strings directly instead of as a front-end to a more general
> | > expect would help.
> | 
> | If you are after speed, I think it would be better to implement a
> | regexp library based on a more generic nondeterministic FSM to
> | deterministic FSM transformer. Then you advance the deterministic FSM
> | on each character you receive. If both machines were scheme data
> | structures, then this same transformer could be used for many other
> | things as well.
> | 
> | I am sorry if this is already thought over or shot down or even
> | implemented. I do not follow these scheme things very closely so just
> | let me know what I am ignorant of.
> 
> This looks like a very promising idea to me.  Nothing has been
> shot down or implemented for the current implementation of expect:
> it's completely unoptimized.
> 
> Interestingly Tom Lord's Rx interface did include regexp->dfa and 
> advance-dfa! among others, so that could be a place to start.

You may want to look in the guile-lang-allover package.  The tools you
need are all there, in a dreadfully messy form.  It includes, among
other things, a packaging of those Rx functions, an NFA->DFA
transformer, a parser (lazy parser generator?) and a complete
programming language implemented using the above.  Unfortunately, the
package as a whole is rather slow.  However, it's a *big* DFA that's
being constructed, and a *big* regular expression that the Rx package
is being asked to handle.  Slow is also measured on a 386.  

In any case, it's probably worth looking at the pacakge.  I would be
happy to answer any questions, but I'm unlikely to be very helpful as
I really don't understand the guts of how the algorithms work.  I just
saw the poor thing languishing in disuse, figured it would be an
interesting exercise to bring up to date, and did.

If you do get that tuned and working (I seem to recall lineio in the
core distribution being a bit of an issue) there have been a few
others on the list interested insimilar things.

Thanks and good luck,
Andrew Archibald
aarchiba@csclub.uwaterloo.ca