• Login
Community
  • Login

FunctionList with prefixed functions

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 3.3k 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.
  • J
    Jeroen6
    last edited by Sep 11, 2015, 11:40 AM

    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
    • P
      Peter Brand
      last edited by Oct 22, 2015, 8:34 AM

      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
      • P
        Peter Brand
        last edited by Oct 22, 2015, 8:59 AM

        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
        • J
          Jeroen6
          last edited by Mar 21, 2016, 6:56 AM

          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){ }

          C 1 Reply Last reply Mar 21, 2016, 5:21 PM Reply Quote 0
          • C
            Claudia Frank @Jeroen6
            last edited by Mar 21, 2016, 5:21 PM

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