From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-07-24 06:47:47
>So, if I understand correctly,
>* the library requires bidirectional iterators (is this documented? I
>able to find it.)
Yes it should be - but a quick search suggests that it's only mentioned in
the introduction - so it looks like an update is required to the docs.
>* the NFA needs the whole [first, last) range since it backtracks, so it
>can't operate in 'incremental' mode, one character at a time.
Yep, although its not the backtracking as such that mandates this - if you
want to be able to return iterators denoting what matched then they have to
be at least forward iterators in any case. The only reason that
bidirection iterators are required is to make it easier to match things
like $ and ^, in some cases.
>OK. So the only way to make an 'incremental' match currently is:
> buffer += get_next_character();
> regex_match(buffer, m, e, match_partial);
>// analyze m
>This would work, but it's very inefficient, since regex_match would have
>'re-match' from scratch every time. Would it be possible to save the
>state to eliminate this inefficiency?
Not easily, BTW since iostream's are buffered already, its a pity that that
mechanism couldn't be hooked into somehow, but I guess that would mean
writing your own stream buffer (not nice). I think the best way to "save
state" as you suggest is to create a smart iterator that pulls more input
into the buffer as and when it needs it - should be pretty quick and easy
to set up as well.
- John Maddock
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk