Error creating a new syntax language

Topics: User Forum
Mar 22, 2010 at 3:01 PM

When creating a new built-in syntax it don't seem to work. I created e2.xml and put it in "Configuration/Builtin" and set it to Embedded Resource. I also made e2.txt and put it in "Configuration/Builtin/LexerStyleNames" Here is the e2.xml and the e2.txt

I am a bit confused why it is not working. Did I forget something? I do know that it is loading the file because when I mistyped Teal my program threw a error.






Mar 23, 2010 at 7:11 PM

<Lexer LexerName="e2" LineCommentPrefix="#">

The lexer name "e2" does not exist. The built-in configuration settings are friendly setups for lexers that Scintilla already supports and that is not one of them. (If you're interested in finding a list of lexers that are supported you can take a look at the Lexer enumeration.) If e2 is similar to the semantics of another programing language you may be able to specify the lexer name of that language and get what you're looking for.

For example: the C# built-in configuration uses the Scintilla C++ lexer because the language semantics are similar enough (although that's not obvious from the cs.xml configuration file).



Mar 23, 2010 at 10:53 PM

Ahh well I took that out and changed the names to match the cpp ones but still no luck.  Xml file is in the back.


So any more ideas?



Mar 23, 2010 at 11:26 PM

In the Lexer config element make LexerName="cpp". It's the job of the lexer to go through the document and decide if a block of text should be a string, keyword, operator, comment, etc. Scintilla comes with dozens of built in lexers for popular languages. In your case having a special custom language you have some choices:

  • Look through the list of built in lexers and try and fine one that matches closely to your language. In this case we're suggesting you try out the c++ ("cpp") lexer.  If you're lucky it will magically work for you and you can move on.
  • Write your own Lexer in c++ according to the Scintilla guidelines. This is quite a monumental task which I wouldn't suggest attempting unless you're a c++ veteran.
  • Write your own styling logic in a .NET language. In the ScIde project look for the custom ini lexer which will give an ideas on how to start. This is easier but still a lot of work. You have to understand the relationship of style definitions relate to document style bytes and other quirks of Scintilla.