User-defined language not styling function parameters
-
The language that I am creating a definition for is C-like. I’ve defined the word ‘byte’ as a keyword and assigned a style to it.
In the Notepad++ editor when editing a file containing source code in this language the correct style and colour is applied when a variable is declared like this:
byte i
… but when using a parameter in a function declaration like below, the style and colour aren’t applied to the word ‘byte’:
void myfunc(byte x) {
}When I look at a C source code file, which uses a built-in language definition, this sort of thing does work.
So is this possible to in Notepad++ for custom language definitions?
-
@Alan-Bourke said in User-defined language not styling function parameters:
‘byte’ as a keyword and assigned a style to it.
(byte x)because you are declare
( )
in delimiter style
use( )
in operator only -
Thanks. I didn’t have ( ) in delimiters or in Operators 1 or Operators 2. It doesn’t work no matter where they are. Also numbers inside square brackets aren’t styled either, but they are styled outside of square brackets.
My operators are:
-> * *' + +' - -' | & ^ >> >>' << <<' >>>> : == != < => <= >= && || =
My only delimiters are:
Open: "
Escape:
Close: "and
Open: ’
Escape:
Close: ’ -
@Alan-Bourke said in User-defined language not styling function parameters:
void myfunc(byte x) {
}if you type
void myfunc( byte x)
then it colors, right?I guess you need to do exactly the opposite and using a delimiter.
Define it with open ( and close ), with the same foreground and background colors as the default style
and make sure to check every possible nesting option (available under styler button). -
@Ekopalypse said :
I guess you need to do exactly the opposite and using a delimiter.
Or, use operators 1 for the parens.
Basically, if parens aren’t defined as anything, then only the rules for
byte
are applied, and the keyword rules (unless the prefix checkbox is marked) say that the keyword doesn’t count if it’s touching anything. However, once you put the( )
in the operators 1, that defines the parens as operators which are allowed to touch anything.(*)If you do use the delimiter # rather than operators 1, you will have to enable nesting for the various keyword # in the delimiter # > styler dialog. [edit: I see @Ekopalypse already mentioned that; didn’t see it on my first read]
*: operators 1 don’t require whitespace to be recognized; operators 2 do require whitespace to be recognized. (This is in https://github.com/notepad-plus-plus/npp-usermanual/blob/master/content/docs/user-defined-language-system.md , and will propagate to https://npp-user-manual.org/docs/user-defined-language-system/ at the next document release.)