Suresh Govindachar wrote:
> Bram Moolenaar wrote:
> >
> > Suresh Govindachar wrote:
> >
> >> Please consider supporting expressions for syntax matching.
> >> An example of usage is indicated below:
> >
> > I don't quite get it. ":syn match" commands use a pattern. You
> > can use ":exec" to get the pattern from an expression.
>
> Good, but how does one use :exec to get the pattern from an
> expression?
>
> As an example expression, the following expression returns 0 or 1
> for line("."):
>
> (
> \ ( foldlevel(line(".")) != foldlevel(line(".")-1) ) &&
> \ ( foldlevel(line(".")) != foldlevel(line(".")+1) ) &&
> \ ( 4 == foldlevel(line('.'))/2 )
> \ )
> \ ? 1
> \ : 0
>
> How would I use exec to get a pattern?
Obviously you can currently only evaluate the expression the moment the
syntax is defined, not when an item is used.
Each item may be used at every character in the file. Evaluating all
the expressions for every item at every character would be very slow.
Even the current mechanism with patterns is slow for some languages, and
it includes all kinds of optimizations to avoid trying a match at every
character and caching the result. With an expression you never know
what it will do, thus these optimizations would not be possible. And
evaluating the expression adds on top of that.
--
Q. What happens to programmers when they die?
A: MS-Windows programmers are reinstalled. C++ programmers become undefined,
anyone who refers to them will die as well. Java programmers reincarnate
after being garbage collected.
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///