Tuesday, February 2, 2010

Re: Syntax region problem

On Wed, 3 Feb 2010, Gregor Uhlenheuer wrote:

> Hi,
>
> I have got a small problem with a syntax region meant to match some
> nested comments in a syntax script.
>
> That's the line:
> syn region mComment start=/\/\*/ end=/\*\// contains=mComment
>
> short example:
>
> /* this should be highlighted as a /* comment */ */
> this text is correctly not highlighted
> this text is correctly not highlighted
> this text is correctly not highlighted
>
> /* this should be highlighted as a /* comment */*/
> this text is highlighted, but shouldn't
> this text is highlighted, but shouldn't
> this text is highlighted, but shouldn't
>
> Somehow the syntax needs that whitespace between the two comment ends,
> but it should not. I hope I described my problem understandable :)

The problem is that the two comment ends back-to-back matches the 'start'
pattern:

i.e.:

'*/*/' = '*/' + '*/'

but, also:

'*/*/' = '*' + '/*' + '/'

I'm not sure of a workaround. Possibly some pointers (or a compromise)
among the following:

:help :syn-keepend
:help :syn-extend
:help :syn-matchgroup

Anyone know of an existing syntax that has this property (nestable
element shares a non-zero start-suffix and end-prefix)?

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: