Notepad++ language template for PureBasic?

For everything that's not in any way related to PureBasic. General chat etc...
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

Here with Macro,Procedure -prefix

Code: Select all

         <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
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Notepad++ language template for PureBasic?

Post by skywalk »

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)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

Need to add other tokens: ProcedureC ProcedureCDLL ProcedureDLL
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Notepad++ language template for PureBasic?

Post by skywalk »

Argg! Forgot about those. Gonna make the parser slow again?
Procedure$ too
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

Code: Select all

(?x)(?mi)^\h*    \K (?:Procedure[CDL$]{0,4}?(?:\.[abcdifqwsu])?|Macro)    \s+  [A-Za-z_]\w*     \s*\([^()]*?\)
Procedure[CDL$]{0,4}?
Procedure$
Where is it used? Does she have a standard look?
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Notepad++ language template for PureBasic?

Post by skywalk »

Procedure$ returns String.
ProcedureDLL$ returns String.
ProcedureC$ returns String.

Code: Select all

			<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!
Last edited by skywalk on Fri Apr 19, 2019 11:33 pm, edited 1 time in total.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

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
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Notepad++ language template for PureBasic?

Post by skywalk »

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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

Code: Select all

(?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: Select all

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

Code: Select all

(?x)(?mi)^\h*(?:Procedure[CDL$]{0,5}?\K(?:\h*\.[abcdfilqsuw])?|Macro)\h+[A-Za-z_]\w*\h*(?=\()
.i GetLineBookmark
.s GetLineText
SetLineText
Macro x
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Notepad++ language template for PureBasic?

Post by skywalk »

Great idea to shorten the list horizontally. :D
I think it better to keep the Procedur\Ke to catch eDLL, e$, eC, etc.

Code: Select all

(?x)(?mi)^\h*(?:Procedur\Ke[CDL$]{0,5}?(?:\.[abcdfilqsuw])?|Macr\Ko)\s+[A-Za-z_]\w*\s*\([^()]*?\)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

1. Check this:

Code: Select all

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.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Notepad++ language template for PureBasic?

Post by skywalk »

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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
AZJIO
Addict
Addict
Posts: 1318
Joined: Sun May 14, 2017 1:48 am

Re: Notepad++ language template for PureBasic?

Post by AZJIO »

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: Select all

;{
;}
I managed to add "Module"

Code: Select all

 <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>
wb2k
User
User
Posts: 18
Joined: Sun Feb 09, 2014 1:22 am

Re: Notepad++ language template for PureBasic?

Post by wb2k »

The background color for every style makes it hard to read, but it looks very good after removing this in your XML-file:

Code: Select all

bgColor="3F3F3F"
Your template is not listed as user definded language at Notepad++ yet:
https://github.com/notepad-plus-plus/us ... dl-list.md
Probably more will use it, if you list it there. Here is how you can contribute your template: https://github.com/notepad-plus-plus/us ... ll-request
Post Reply