This project is read-only.

Cannot use the single quote as a comment start character

Topics: User Forum
Mar 17, 2013 at 2:25 AM
I have gotten most of syntax highlighting, basic autocomplete and basic CallTips working, but still have one lingering problem with syntax highlighting.

In the language for which I am trying to provide syntax highlighting, a single quote ' specifies a full line comment. However, this is used for chars in ScintillaNET.

As a workaround, I decided to use the char settings (since the ' line comments are processed as chars by ScintillaNET and there are no chars - just strings - in the language) for my comments. Everything works fine except for one thing. Since the whole line is a comment, it does not need to be closed by a matching single quote '. However, unless it is closed by another single quote ', the section is rendered as red text on a green background.

Is there a way to stop chars from having to be terminated by a matching single quote?
Mar 17, 2013 at 7:44 AM
Generally the classification of code is handled by the lexer which is the realm of Scintilla not ScintillaNet. What language is this?
Mar 17, 2013 at 5:33 PM
Thanks for the reply! The language is Microsoft Small Basic (for which there is no default lexer).

Since this is an issue in the native Scintilla, would a regex-based custom lexer (like the INI lexer) be the best way to go?
Mar 17, 2013 at 6:34 PM
You might want to look at using the VB or VBScript lexer, both already use a single quote for a full line comment.
Mar 18, 2013 at 12:16 AM
Thanks for the tip! It is working well.

However, now, for example, the following line:

TextWindow.WriteLine

will not highlight correctly: individually "TextWindow" and "WriteLine" will be highlighted correctly (classes have their own keyword set; as do members), but the dot "." stops either from being highlighted. With the C# / C++ lexer this works fine. Is there any way to fix this or is it built into the native scintilla? (I tried adding the dot to the whitespace characters but that did not help)

If I should start a new thread for this, please tell me =)
Mar 18, 2013 at 1:09 AM
Well, after looking, it appears that the VB and VBScript lexers treat a dot as an identifier character, so it treats the entire thing as one keyword. This is built-into the trunk branch, but I do have control over it in the WPF branch (because the VB and VBScript lexers are both written in C# in that branch), and have added a SmallBasic lexer which functions the exact same as the VB and VBScript lexers, except that it doesn't include a dot as an identifier character.
Mar 18, 2013 at 2:59 AM
Thanks for all the help! I will port my IDE to use the latest branch and use your new lexer.