Page 1 of 1

Colouring variables

Posted: Wed Jan 21, 2026 6:52 pm
by charvista
Colouring in the editor is nice, but I think that:

1) 'Normal Text' should be called 'Variables' as I see that only variables have that colour.
2) Arrays have the same colour as 'Functions'. It should be the same colour of 'Variables', because an array is a dimensioned variable, not a function.

Re: Colouring variables

Posted: Wed Jan 21, 2026 8:26 pm
by STARGĂ…TE
The Syntax Highlighting of the PureBasic editor (Scintilla gadget) is based on the regular expression.
This regex can't distinguish if "name(value)" is a procedure "name" with parameter "value" or an array "name" with the index "value" or a map "name" with the key "value". Therefore the color is same for all.

A coloring, like the one you want, would require a live compilation of the code to determine whether an identifier was previously defined as an array or a procedure.

Re: Colouring variables

Posted: Wed Jan 21, 2026 9:38 pm
by charvista
Hm, I undertand now why...

But what you are telling : "... would require a live compilation of the code to determine..." gives me an idea that only Fred can do, is to create a sort of line compiler.

C$ = LineCompile(line$) and would return a sort of compiled code with tokens for each element of the line. With that, it would be possible to determine whether it is a function or an array.

Perhaps there are more advantages involved...

Re: Colouring variables

Posted: Wed Jan 21, 2026 11:25 pm
by SMaag
But what you are telling : "... would require a live compilation of the code to determine..." gives me an idea that only Fred can do, is to create a sort of line compiler.

C$ = LineCompile(line$) and would return a sort of compiled code with tokens for each element of the line. With that, it would be possible to determine whether it is a function or an array.

Perhaps there are more advantages involved...
Maybe in the near future we can do on the fly Parsing of PB-Code!
I'm working on a Cross-Reference Tool for Log-Files what should parse Gigabyte Files and create a full Cross-Reference List of all Words/KeyWords ...

Primiary it is not for PB-Code. But generally it works for all TextFiles. For the ProofOfConcept implementation I created a big PB-Code-File of aprox 60K of Lines and I was surpriesed from the speed.

Here the Output: Ryzen 5800 single Task!
No of Codelines = 59368
Time to parse ms = 107
Total amount of Words = 89591
Different Words found = 14457

First 10 Words
Average
Automatic
Automated
AutoInit
AuthenticAMD
Attribute_Value
Attribute
AsyncRead
AsyncProperty
Assessment_Specification
AsmCodeIsInProc
I tried the IDE Tool 'FindAllReferences' from PB-Forum what need
- 43sec to list all Procedures
- 45sec to list all Structures

If the high speed of my tool keeps stable at further development. I guess this might be a tool for the PB-IDE in the Future!
FindAllReferences use Regular Expression what is a great tool. But compared to native character operation the Regular Expression is slow.

I do native word parsing with some additional tricks to speed up.
The heart is a FastCharacter classification Tool what minimize the Character compare operations by using a kind of LookUpTable!

At the moment it is a quick and dirty ProofOfConcept Implementation. But as soon as I have reliable code, I will publish it.

Re: Colouring variables

Posted: Thu Jan 22, 2026 12:27 am
by charvista
Sound interesting.
I am very optimistic about the evolution of PureBasic.