Community
    • Login

    FunctionList with prefixed functions

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 3.6k Views 2 Watching
    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.
    • Jeroen6J Offline
      Jeroen6
      last edited by

      The notepad function list does not seem to recognize interrupt functions which require a specific keyword to the compiler.
      _interrupt(T1_INT) void T1_Overflow_ISR(void){
      This works though.
      _interrupt void T1_Overflow_ISR(void){

      I’ve tried to edit the match in the functionList.xml. But regex is a true art I do not master.
      ^[\t ]*((static|const|virtual|_interrupt\([^\)\(]*\))[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{

      Is is possible to have notepad understand functions prefixed with _interrupt(ANY) ?

      1 Reply Last reply Reply Quote 0
      • Peter BrandP Offline
        Peter Brand
        last edited by

        The clause ‘_interrupt([^)(]*)’ says find the word _interrupt followed by a bracket then 0 or one of: anything not a closing or opening bracket followed by a bracket. The * operator is ‘greedy’, so in the first example it considers ‘(T1_INT) void T1_Overflow_ISR(void)’ as one chunk from the first opening bracket to the last, and finds opening and closing brackets within it, so it rejects it. To make it non-greedy so that it stops at the first closing bracket, use ? as so '_interrupt([^)(]?)'.

        However, since the brackets after _interrupt are optional, it might be clearer to use ‘_interrupt((.*?))+’ which reads: find _interrupt followed by 0 or 1 of: opening bracket, some characters non-greedy, closing bracket).

        1 Reply Last reply Reply Quote 0
        • Peter BrandP Offline
          Peter Brand
          last edited by

          Oops, should have used markdown in my reply above.

          To make it non-greedy so that it stops at the first closing bracket, use a ‘?’ after the ‘*’ as so:

           _interrupt\([^\)\(]*?\) 
          

          However, since the brackets after _interrupt are optional, it might be clearer to use

          _interrupt(\(.*?\))+
          

          which reads: find _interrupt followed by 0 or 1 of: opening bracket, some characters non-greedy, then closing bracket).

          1 Reply Last reply Reply Quote 0
          • Jeroen6J Offline
            Jeroen6
            last edited by

            Took some time, but I’m working on a project with these features again.

            Well, I’ve tried it. But too bad, it doesn’t work.

            Meanwhile the solution is just to add this one line higher.
            void T1_Overflow_INT(void){ }

            Claudia FrankC 1 Reply Last reply Reply Quote 0
            • Claudia FrankC Offline
              Claudia Frank @Jeroen6
              last edited by

              Hello @Jeroen6,

              this should do the trick, I hope I didn’t break any other functions.
              It’s basically Peter Brands proposal with a little modification (using * instead of +, as it is optional)
              and introduced a new nameExpr to catch the interrupt functions.

                      <parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
                          <function mainExpr="^[\t ]*((static|const|virtual|_interrupt(\(.*?\))*)[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|(\*|\*\*)[\s]+|[\s]+(\*|\*\*)|[\s]+(\*|\*\*)[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"	displayMode="$functionName">
                              <functionName>
                                  <nameExpr expr="(?!_interrupt(\(.*?\))*) [\w_~]+[\s]*\("/>
                                  <nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
                                  <nameExpr expr="(?!(if|while|for))[\w_~]+"/>
                              </functionName>
                          </function>
                      </parser>
              

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors