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

Extending the CPP Lexer

<< < (2/4) > >>

Malc:
So if I do this, what would need to be modified?  It looks to me like just the wordlist array.  Anything else?

Folco:
If you want to add a lexer, you have to modify :
src/sdk/wxscintilla/src/scintilla/src/Catalogue.cxx
src/sdk/wxscintilla/Makefile.am
src/sdk/wxscintilla/src/scintilla/include/SciLexer.h
src/sdk/wxscintilla/src/scintilla/include/Scintilla.iface
src/sdk/wxscintilla/include/wx/wxscintilla.h

In your lexer_language.cxx, you must define the entry points of the keyword list that you want to use (indexes are here !). Example :
    WordList &cpuInstruction = *keywordlists[0];
    WordList &registers      = *keywordlists[1];
    WordList &directive      = *keywordlists[2];
    WordList &extInstruction = *keywordlists[3];
    WordList &alert          = *keywordlists[4];
    WordList &doxygenKeyword = *keywordlists[5];

Then you must export that, in the same source file :
static const char * const a68kWordListDesc[] =
{
    "CPU instructions",
    "Registers",
    "Directives",
    "Extended instructions",
    "Alerts",
    "Doxygen keywords",
    0
};

That is the right way to define new indexes and keyword lists.

MortenMacFly:
... I would seriously suggest you first contact and discuss any changes with the maintainer of scintilla (http://www.scintilla.org/ScintillaToDo.html). He is known to be very restrictive. And what won't make it into scintilla itself most likely also won't make it into C::B.

Malc:
So Folco, are those first file modifications needed if you are modifying an existing lexer?  Should just be the extension of the wordlists themselves, correct?

Morten, unless the Scintilla maintainer is willing to add the changes in himself, I'm not really concerned about it.  I can just compile it myself and call it good.

:)
Malc

Alpha:
There are other modifications.  Follow the variable keywords2 around LexCPP.cxx and do a threaded searches for SCE_C_WORD2 and wxSCI_C_WORD2.  That should provide an example, and the locations for modifications.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version