How to add Keyword class to cause highlighting



  • Hi I am trying to add a few new keywords to Verilog language. I have been studying this thread which has been quite helpful in creating a new Keyword Class “type1” for Verilog and giving it its own set of keywords.

        <Language name="verilog" ext="v sv vh svh" commentLine="//" commentStart="/*" commentEnd="*/">
            <Keywords name="instre1">always and assign attribute begin buf bufif0 bufif1 case casex casez...
            <Keywords name="instre2">SYNTHESIS $assertkill $assertoff $asserton $bits $bitstoreal...
            <Keywords name="type1">test_word1 test_word2</Keywords>
        </Language>
    

    I add this also to the stylers.xml:

        <LexerType name="verilog" desc="Verilog" ext="">
              ...
            <WordsStyle name="SPECIAL WORD" styleID="22" fgColor="A082BD" bgColor="293134" keywordClass="type1"></WordsStyle>
              ...
        </LexerType>
    

    The problem is that even though the style configuration can see the new keyword Class, it does not actually apply any syntax highlighting to any keywords in the new class…

    When I open the Style Configurator, I can see the “SPECIAL WORD” category with the correct color and Default Words come up, but then the words are not actually highlighted in the files with the appropriate extensions (*.v, *.sv, *.vh, etc.). Furthermore adding new user-defined keywords to the SPECIAL WORD category doesn’t cause them to be highlighted either. I have tried changing the styleID a few times…



  • @A-Stod

    Verilog supports only two keyword lists, which are already used as instre1 and 2

    void setVerilogLexer(){
        setLexer(SCLEX_VERILOG, L_VERILOG, LIST_0 | LIST_1);
    

    Cheers
    Claudia



  • Oh I see. And it’s not possible to modify this right?



  • @A-Stod

    depends, of course you can change the code and recompile your own version,
    but with the standard npp exe, no, not yet.
    What you can do is opening an enhancement request here and ask for changing it.

    Maybe @dail 's new scintillua plugin might help you in the meantime but I haven’t had a chance to investigate what it can do or can’t.

    Cheers
    Claudia



  • Thank you for your help.

    Would you be so kind as to point me to exactly which files need to be edited to add another Keyword Class as well as a URL for a webpage containing the steps of how to recompile my version?



  • @A-Stod

    What needs to be done in regards of compiling npp and scintilla is described here.

    The file in question is ScintillaEditView.h.
    Whether this is the only place which needs to be modified or not I don’t know
    as I haven’t done it myself yet. But when you do have c++ knowledge you should be able to find out.

    Cheers
    Claudia



  • @A-Stod

    side note, the lexer itself (LexVerilog.cxx) is capable of using 6 keyword groups.

    class LexerVerilog : public ILexerWithSubStyles {
        CharacterSet setWord;
        WordList keywords;
        WordList keywords2;
        WordList keywords3;
        WordList keywords4;
        WordList keywords5;
        WordList ppDefinitions;
    

    and if you do it yourself it would be nice to let us know what you did,
    so that the next one could benefit :-)

    Thx and cheers
    Claudia



  • I’ll give it a shot. If I am successful, I’ll for sure reply back


Log in to reply