• Login
Community
  • Login

User-defined language not styling function parameters

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 4 Posters 649 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.
  • A
    Alan Bourke
    last edited by Alan Bourke Sep 19, 2019, 7:56 AM Sep 19, 2019, 7:55 AM

    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
    • R
      rinku singh
      last edited by rinku singh Sep 19, 2019, 8:54 AM Sep 19, 2019, 8:54 AM

      @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
      • A
        Alan Bourke
        last edited by Alan Bourke Sep 19, 2019, 10:30 AM Sep 19, 2019, 10:30 AM

        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
        • E
          Ekopalypse
          last edited by Ekopalypse Sep 19, 2019, 10:41 AM Sep 19, 2019, 10:40 AM

          @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
          • P
            PeterJones
            last edited by PeterJones Sep 19, 2019, 1:14 PM Sep 19, 2019, 1:13 PM

            @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
            4 out of 5
            • First post
              4/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors