Handling languages with different syntax

Topics: User Forum
Jul 29, 2008 at 7:06 PM

I'd like to use ScintillaNET with two languages, neither of are supported by the current built-in languages.

Neither is especially radical; one is assembly and the other is BASIC. In the case of the former I'd need to handle /* */ comments as well as ; comments, and in the case of the latter I need it to be case sensitive, not something that appears to be possible using the built-in lexer.

I've noticed that setting a particular language with Scintilla.ConfigurationManager.Language = "<language>"; works nicely, but then doing something like Scintilla.Lexing.LineCommentPrefix = "#"; (for example) doesn't seem to do anything. I can't see any documentation for this project.

What's the best way to go about this? Will I need to write a custom, unmanaged lexer -- and if so, where would I need to look for instructions?

Cheers for any advice!

Coordinator
Jul 29, 2008 at 10:55 PM
If you're setting the comment  properties through code you have to make sure and set them after you set a language, otherwise the configs may override them.Alternatively you can create your own language config that has these values. See http://www.codeplex.com/ScintillaNET/Thread/View.aspx?ThreadId=22898 on how to do this.

I don't know if you need a custom lexer for assembly or not. There is a built in one called asm but I don't know if it's quite the flavor of assembly you need. It may be though that all you need to do is fill out the keywords.

However if you want case sensitive basic you are going to need to write your own unmanaged lexer, as Scintilla lexers can't be written in managed code. See http://scintilla.sourceforge.net/Lexer.txt. I suggest you just take the existing basic lexer and make it case sensitive, as it's the easiest route.

Jul 30, 2008 at 1:14 AM
Thanks for your reply. I think writing a new unmanaged lexer is going to be the easiest solution for both routes. :-)