On 5/6/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

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.

What if syn expression be evaluated once per-line not once per-char,
and then return either one value (if  HL applies to whole line)
or list of columns (if HL varies within the line) ? Wouldn't this
be faster than applying exptr for every char ?

Yakov

Reply via email to