On Tue, Mar 01, 2016 at 04:46:19PM +0000, Connor Lane Smith wrote: > On 29 February 2016 at 18:51, Greg Reagle <greg.rea...@umbc.edu> wrote: > > Another approach would be to write a structural regexp library. Then > > structural regexp's could be available to other programs. > > I've been thinking about this, actually. What might be even better is > a regular expression library which just makes it easy to build > structural regular expressions on top of it. The interfaces of common > libraries, be they Unix or Plan 9 or RE2, are not sufficiently > expressive to support this
Why do you think that? You just have to be able to match a regular expression against a given range of text which should be possible to do with any regexp library. It might not be efficient, but it should work. However I agree, although with different reasoning, that the standard regex(3) interface is not sufficient for an efficient editor handling arbitrary input: - For starters only NUL-terminated strings can be matched - No integration with editor specific data structures is possible. Ideally the regex engine would have a way to ask for further input if it needs it. Instead vis currently has to temporarily copy the whole document content into contiguous memory area even if the next match is only a few characters away. - Backward search is not possible efficiently. I believe sam has a particular elegant mechanism for this, it basically reverses every transition of the automaton implementing the regexp. > This would require quite careful planning of the library's API in > order to work well, though. I'm giving it some thought at the moment > anyway. If you decide to write a regex engine then please also take the above points into consideration. The corresponding section of the vis README[1] also has a few links to existing engines / algorithms used etc. [1] https://github.com/martanne/vis#efficient-search-and-replace -- Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: 10C93617