Bram Moolenaar wrote:
> Brett Stahlman wrote:
>
...snip...
>> *** CASE 1 ***
>> syn region a start=/a/ end=/A/ nextgroup=after_a skipnl
>> syn region after_a start=/\%(A\n\?\)\@<=/ end=/B/ contained
>> hi link a Comment
>> hi link after_a Error
>>
>> Note: This one works as expected. Both occurrences of region a are
>> highlighted as Comment. Both occurrences of region after_a are
>> highlighted as Error.
>>
>> *** CASE 2 ***
>> syn region a start=/a\@<=/ end=/A/ nextgroup=after_a skipnl
>> hi link a Comment
>> syn region after_a start=/\%(A\n\?\)\@<=/ end=/B/ contained
>> hi link after_a Error
>>
>> Note: This one doesn't work at all. The only difference between this
>> case and case 1 is that the `start=' for this one uses a positive
>> look-behind assertion to match the a.
>>
>> *** CASE 3 ***
>> syn region a start=/a\@<=/ end=/A/
>> hi link a Comment
>>
>> Note: Region a is highlighted as Comment. This seems odd to me, since
>> the start and end patterns for case 2 and 3 are identical. In fact, the
>> only difference in the region a definitions is that case 2 contains a
>> nextgroup and skipnl. Although these attributes are supposed to
>> determine only what happens after a region ends, they appear to be
>> preventing the region a start pattern from matching in case 2. Is this a
>> bug or is there a subtlety regarding nextgroup and look-behind
>> assertions that I'm missing?
>
> You try to use a start pattern that is zero width. This confuses the
> logic. Try putting a dot in the pattern, e.g.:
>
> syn region a start=/a\@<=./ end=/A/ nextgroup=after_a skipnl
The start pattern is zero-width by design, as the region it introduces
may be empty. I believe I could structure things so as to use only "case
1" (i.e., zero-width look-behind only in the start pattern of the region
introduced by nextgroup); however, not knowing whether it's working by
design or by accident makes me hesitate to use the zero-width
look-behind in the start pattern at all. I have an alternate approach
that works, which I'll probably end up using. The strange thing to me is
that the zero-width start pattern doesn't cause any problems in case 3.
Oh well.
Thanks,
Brett S.
>
> I'm not sure if what you see in case 2 is a bug or undefined behavior.
>
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---