PureBasic Forum
https://www.purebasic.fr/english/

Notepad++ language template for PureBasic?
https://www.purebasic.fr/english/viewtopic.php?f=17&t=41069
Page 4 of 4

Author:  AZJIO [ Fri Apr 19, 2019 10:46 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Here with Macro,Procedure -prefix
Code:
         <parser
            displayName="PureBasic"
            id         ="purebasic_function"
            commentExpr="(?x)(?m-s:^\h*;.*?$)  # !Single line comment"
         >
            <function
               mainExpr="(?x)(?mi)^\h*    \K (?:Procedure(?:\.[abcdifqwsu])?|Macro)    \s+  [A-Za-z_]\w*     \s*\([^()]*?\)"
            >
               <functionName>
                  <nameExpr expr="[\w\s.]+"   />
               </functionName>
            </function>
         </parser>

skywalk wrote:
What version of Notepad++ are you running?

7.6.6 x86

Author:  skywalk [ Fri Apr 19, 2019 10:58 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Whew! My slowness was a malformed functionList.xml.

You are missing Procedure.l?
mainExpr="(?x)(?mi)^\h*\K(?:Procedure(?:\.[abcdfilqsuw])?|Macro)\s+[A-Za-z_]\w*\s*\([^()]*?\)"

Great Job! Yours is running much faster. 8)

Author:  AZJIO [ Fri Apr 19, 2019 11:06 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Need to add other tokens: ProcedureC ProcedureCDLL ProcedureDLL

Author:  skywalk [ Fri Apr 19, 2019 11:10 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Argg! Forgot about those. Gonna make the parser slow again?
Procedure$ too

Author:  AZJIO [ Fri Apr 19, 2019 11:18 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Code:
(?x)(?mi)^\h*    \K (?:Procedure[CDL$]{0,4}?(?:\.[abcdifqwsu])?|Macro)    \s+  [A-Za-z_]\w*     \s*\([^()]*?\)

Procedure[CDL$]{0,4}?

Quote:
Procedure$
Where is it used? Does she have a standard look?

Author:  skywalk [ Fri Apr 19, 2019 11:25 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Procedure$ returns String.
ProcedureDLL$ returns String.
ProcedureC$ returns String.
Code:
         <parser
            displayName="PureBasic_Dark"
            id         ="purebasic_function"
            commentExpr="(?x)(?m-s:^\h*;.*?$)  # !Single line comment"
         >
            <function
          mainExpr="(?x)(?mi)^\h*\K(?:Procedure[CDL$]{0,5}?(?:\.[abcdfilqsuw])?|Macro)\s+[A-Za-z_]\w*\s*\([^()]*?\)"
            >
               <functionName>
                  <nameExpr
              expr="[\w\s\$.]+"
            />
               </functionName>
            </function>
         </parser>
Don't forget the l for Long!

Author:  AZJIO [ Fri Apr 19, 2019 11:33 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

skywalk wrote:
Procedure|ProcedureC|ProcedureDLL

Procedure(?:C|DLL|CDLL)?
In your version, the engine will go back 9 characters to check the word first.
For example, we allow a slightly wrong code. But no one will write the wrong code. We don't need to perfectly detect

Author:  skywalk [ Fri Apr 19, 2019 11:35 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Yes, you are a REGEX wizard. This is my 1st use of this nasty scripting. I must say, I still hate it. :twisted:

Main thing is I now have Notepad++ running quicker.
It was like a turtle in sand with my version on large files.

Author:  AZJIO [ Fri Apr 19, 2019 11:48 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Code:
(?x)(?mi)^\h*\K(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?|Macro)\h+[A-Za-z_]\w*\h*\([^()]*?\)

(?x)(?mi)^\h*\K(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?|Macro)\h+[A-Za-z_]\w*\h*\([^()]*?\)
Procedure .s - space is allowed
\s+ -> \h+ we only have horizontal spaces

Code:
(?x)(?mi)^\h*(?:Procedu\Kre[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?|Macro)\h+[A-Za-z_]\w*\h*(?=\()

Procedu\Kre - So shorter
Quote:
re.s GetLineText
re SetLineText



Code:
(?x)(?mi)^\h*(?:Procedure[CDL$]{0,5}?\K(?:\h*\.[abcdfilqsuw])?|Macro)\h+[A-Za-z_]\w*\h*(?=\()

Quote:
.i GetLineBookmark
.s GetLineText
SetLineText
Macro x

Author:  skywalk [ Sat Apr 20, 2019 2:21 am ]
Post subject:  Re: Notepad++ language template for PureBasic?

Great idea to shorten the list horizontally. :D
I think it better to keep the Procedur\Ke to catch eDLL, e$, eC, etc.
Code:
(?x)(?mi)^\h*(?:Procedur\Ke[CDL$]{0,5}?(?:\.[abcdfilqsuw])?|Macr\Ko)\s+[A-Za-z_]\w*\s*\([^()]*?\)

Author:  AZJIO [ Sun Apr 21, 2019 6:35 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

1. Check this:
Code:
Procedure .s FuncName ()
   ProcedureReturn "Good"
EndProcedure
Debug FuncName ()

Will show it in the list of procedures
2. Look at this https://notepad-plus-plus.org/community ... -purebasic
I think if to offer it for Notepad ++, then it has to show only names of procedures.

Author:  skywalk [ Sun Apr 21, 2019 7:38 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Good deal. I didn't know the L_Purebasic id? I still use userDefinelang because I changed the theme to Dark and built in is not.

Author:  AZJIO [ Sun Apr 21, 2019 9:05 pm ]
Post subject:  Re: Notepad++ language template for PureBasic?

Quote:
I still use userDefinelang because I changed the theme to Dark and built in is not.

Color theme is not difficult to do, here is my example. But the parser itself is imperfect, it contains few tokens.
Yesterday I updated userDefineLang-PureBasic. I added the area
Code:
;{
;}


I managed to add "Module"
Code:
 <parser
   displayName="PureBasic"
   id         ="purebasic_function"
   commentExpr="(?x)(?m-s:^\h*;.*?$)  # !Single line comment"
 >
   <classRange
      mainExpr    ="(?x)(?mi)^\h*Module\h+\K[A-Za-z_]\w*\s+.+?(?=EndModule)"
   >
      <className>
         <nameExpr expr="\w+" />
      </className>
      <function
         mainExpr="(?x)(?mi)^\h*(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?\K|Macro)\h+[A-Za-z_]\w*\h*(?=\()"
      >
         <functionName>
            <funcNameExpr expr="[\w\h.$]+" />
         </functionName>
      </function>
   </classRange>
   <function
         mainExpr="(?x)(?mi)^\h*(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?\K|Macro)\h+[A-Za-z_]\w*\h*(?=\()"
   >
      <functionName>
        <nameExpr expr="[\w\h.$]+"   />
      </functionName>
   </function>
 </parser>

Page 4 of 4 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/