home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dove!cme!libes
- From: libes@cme.nist.gov (Don Libes)
- Newsgroups: comp.lang.tcl
- Subject: Re: Expect: Why doesn't interact have the -re flag?
- Message-ID: <20225@muffin.cme.nist.gov>
- Date: 20 Nov 92 19:06:30 GMT
- References: <1992Nov16.023611.24765@midway.uchicago.edu>
- Organization: National Institute of Standards and Technology
- Lines: 47
-
- In article <1992Nov16.023611.24765@midway.uchicago.edu> pynq@midway.uchicago.edu writes:
- >I would like to be able to either match strings with reg exps in
- >interact (and be able to check back to see exactly what was matched)
- >a la expect (with -re). I could see no way to do this.
-
- I'm actually working on this right now. It's tricky because you have
- to consider the possibility of matching if more characters might
- arrive later. Interact already does this with fixed strings, but it's
- more challenging with regular expressions.
-
- Imagine the pattern "a.*c|b" with input of "ab". With the "usual"
- regexp interpretation, this would match the second branch. However,
- if we waited for a "c" to arrive, then the first branch would match.
- Note that the first branch starts earlier than the second branch.
- Does this mean the "might match" is preferable to the "match"? Before
- you say "the match is always preferable", think about other examples.
- Consider all the useless computation that might take place should no
- match actually occur after a "might match". Maybe we should just stop
- after the first "might match".
-
- For now, I'm taking the approach that the earliest branch is best
- whether or not it is "match" or "might match".
-
-
- This work is part of a complete rewrite of "interact". The new one
- will support the following:
-
- m-to-n mapping of sources to sinks
- optional echoing of patterns
- regexp patterns
- timeout/eof patterns for each source
- Am I leaving out anything?
-
- >Alternatively, if I could do an explicit I/O that would work, too, a la:
- >
- >interact {
- > -o foo { somekindofreadstmthere spawn_id var
- > if {var == "bar"} ...
- > if {var == "d"} ...
- > }
- > }
- >
- >Well, you get the idea...
-
- You can do this. Just use an "expect" to do your "somekindofreadstmthere".
-
- Don
-