2009/6/12 Taylor Venable taylor@metasyntax.net:
I'm trying to write a parser combinator library, and part of that entails some rewinding of streams for ordered-choice operations (as illustrated above). A potential alternative would be to duplicate the port's contents and use a different port for each alternative, but I am not aware of any API to do this either. Any ideas on how to accomplish this objective?
I realize this is not what you are looking for, but when I hit this kind of problem in the lisp world, I found that life became much simpler by using a list of chars than by using string-ports (or ports of any kind for that matter). Yes it's expensive in terms of memory, but it's not that often that you need to keep the original full text very far into the computation...
david rush