John Salerno wrote:
Thanks. But the only list I see in the Python lexer is the list of
actual Python keywords. I assume method and function names are read
from the API file.

But what if I want to add additional words to highlight that are not
keywords? The two examples I gave, for instance, are 'self' and
exception names, neither of which are keywords and both of which I'd
like to highlight differently than keywords. So is there a way for me
to define new lists of words, such as one for exceptions?

The C++ code of a lexer says how many keyword lists are defined/used by that lexer - so adding a new list just by changing the .properties file is not going to happen *in general*.

Internally, a generic lexer will do tokenizing based on the rules of that language. When it has identified a token that *could* be a "keyword" in that language, it will typically check this against the various "keyword" lists from its .properties file.

This is the sense of the "keywords" we are talking about here - which may or may not bear a close resemblance to the "keywords" defined by a language's grammar. This process can also be somewhat different from what I have described, e.g., because of rules about shortest/longest matching etc.

Anyway, if the .properties file already has a "keyword" list that matches what you want in terms of appearance (font, color, weight), and your desired new entry *could* be in that list based on the tokenizing rules, then adding to that list will probably work.

But I think this is about the limit of what you can do without hacking said lexer to define *new* keyword lists. YMMV.

As it happens, the Python lexer seems to define an additional keyword class it refers to as "Highlighted identifiers"... to use this, just edit your python.properties and add something like

keywords2.$(file.patterns.py)=self MyException

Note that this will use style# 14 for coloring info when the tokens self or MyException are encountered in Python source.

Since Neil is "Mr Python" around here, he might have other comments to add regarding the intended use of this feature of the Python lexer.

Robert Roessler
[EMAIL PROTECTED]
http://www.rftp.com
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to