Community
    • Login

    User-defined language not styling function parameters

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 638 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alan BourkeA
      Alan Bourke
      last edited by Alan Bourke

      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?

      1 Reply Last reply Reply Quote 1
      • rinku singhR
        rinku singh
        last edited by rinku singh

        @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

        1 Reply Last reply Reply Quote 0
        • Alan BourkeA
          Alan Bourke
          last edited by Alan Bourke

          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: ’

          example

          1 Reply Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse
            last edited by Ekopalypse

            @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).

            1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones
              last edited by PeterJones

              @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.)

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors