Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Extending the CPP Lexer

(1/4) > >>

Malc:
I've looked at the code, and it looks as simple as just adding another line to cppWordLists[] in LexCPP.cxx, but I wanted to check first.  I need support for a 3rd set of Keywords.  Using the existing CPP Lexer, I have found I can highlight comments, preprocessor stuff (index 9), primary keywords (index 0) like bool int float etc, and secondary keywords.  I can't get a third set working though within the bounds of the existing lexer.

The purpose of this is for another c-type language that has many global functions, as well as local functions, and I want them highlighted separately.  The language is LPC, in case someone already has support for it  ;D which would be even better.  I want to switch from VIM to CB ;D

Thank you,
Malc

MortenMacFly:
Did you try menu "Settings" -> "Editor" -> "Syntax Highlighting" -> Button "Keywords" first? Here you can setup additional user keywords for each (!) lexer. I think this is way better than hacking scintilla (the lexer's code) itself.

Alpha:
I think the easiest (and probably best) way to support this language would be to copy lexer_cpp.xml to lexer_lcp.xml and modify the file masks and keywords.  However, this would still only give you two color sets for highlighted keywords, and if I am understanding you correctly, you want three, right?

Malc:

--- Quote from: MortenMacFly on July 12, 2012, 07:43:54 am ---Did you try menu "Settings" -> "Editor" -> "Syntax Highlighting" -> Button "Keywords" first? Here you can setup additional user keywords for each (!) lexer. I think this is way better than hacking scintilla (the lexer's code) itself.

--- End quote ---

Yes, this would be easier, but still does not allow for a 3rd set.  For example, you can enter 1-9.  But if I use '4', as an example, those words are not highlighted.


--- Quote from: Alpha on July 12, 2012, 05:42:27 pm ---I think the easiest (and probably best) way to support this language would be to copy lexer_cpp.xml to lexer_lcp.xml and modify the file masks and keywords.  However, this would still only give you two color sets for highlighted keywords, and if I am understanding you correctly, you want three, right?

--- End quote ---
Correct.  I started out this way, experimenting with indexes and such as well.  But I cannot get 3 sets of keywords :(

Alpha:
In that case, modifying LexCPP.cxx might be your only option.  If you go through with this, you also should talk to the Scintilla people to try to get it in their repository.  (Code::Blocks uses a mostly unmodified copy of Scintilla.)

Navigation

[0] Message Index

[#] Next page

Go to full version