Having trouble with lookahead regex in a syntax highlighting mode
Submitted by Tuesday, 27 June, 2006 - 15:26
on
In the particular language I am writing a mode for, the start and end of code blocks are delimited by { }. Code appears within these braces. So, it's a little like ?> except with different symbols.
Within these braces, *everything* after a double slash - // - is a comment... right to the end of a code block (not just on the same line).
For example:
{ some code // this is
a comment }
Now, the syntax I first tried was:
//
}
However, this interferes with the match for the end of the code block, and so the end } is not detected correctly.
I then tried:
//
(?=})
...which I think should do the trick, as the lookahead should trigger a match upon encountering the end brace, but not include it in the match, so it should still be there for the code block rule to find. The trouble is, it doesn't match anything at all! Further experimentation seems to suggest that the END block cannot actually contain regex - just the BEGIN block. If so, this is pretty useless, so I have to assume I'm doing something wrong.
Can anyone help me out and show me how to accomplish what I want?
Thanks!