Disabling Whole Line Sytax Highlighting for Style

Topics: Developer Forum, User Forum
May 3, 2012 at 1:23 PM
Edited May 3, 2012 at 1:23 PM

I'm attempting to create my own language with its own set of syntax highlighting rules. Ideally, the preprocessor directive "#define" would appear in blue, with the rest of the text on the line remaining in the default black color. Unfortunately, the style definition for preprocessor directives, ie.


<Style Name="PREPROCESSOR" ForeColor="Blue"/>


causes the entire line preceded by the hash tag to take on the color blue, not just the keyword "#define".

In an attempt to make only "#define" appear in blue text, I've changed the preprocessor style to color the text black and added "#define" to the list of keywords. This does not seem to work, as the style seems to take precedence over keyword coloring and the whole line just appears in black.

Is there a way to disable this style and add "#define" as a keyword? Or, alter the way this particular style is applied, making it only highlight the single keyword rather than the entire line?

May 18, 2012 at 4:30 AM

I haven't actually tested this but my guess would be 'no'. I assume you are using the C++ lexer as the base for your language. Depending on the way the lexer is written it will likely treat your #define line as a preprocessor directive regardless of whether you've added "#define" to the keyword list. Or in other words, how the #define line is styled is determined by the lexer and out of your control.

The only way that I think you're going to get the level of control you want is to write your own lexer. It's a daunting task but if you are deviating--only slightly--from the original language the lexer was intended for you're going to be fighting an uphill battle.