help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: will we ever have zero width assertions in regexps?


From: Stefan Monnier
Subject: Re: will we ever have zero width assertions in regexps?
Date: Mon, 31 Jan 2011 16:29:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> So you have a REx which is matched against a line, but you want (in
> addition to the usual effects of matching) to know whether it "wanted"
> the match to overflow into the following line?

> If so, it looks like "reusing the continuation state" would not be a
> serious optimization - it would add just a small multiplicative
> constant to the "use only the hypothetical bit" scenario...

We could probably make it work with just that extra bit, indeed.
But with the full intermediate state, we get to just "start the search
with last line's state" instead of having to "start the search from the
previous N lines since they all ended with the <wantmore> bit set", so
it will happily work with many-lines cases without having to reparse
those many lines N times.

Admittedly, in most cases, font-lock element should not be long (in most
cases, such long elements should be handled differently, e.g. via things
like font-lock-syntactic-keywords, marking the beginning and the end of
the long element), but again, it's good to handle pathological cases,
because sooner or later users will bump into them.


        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]