Colouring variables

Working on new editor enhancements?
User avatar
charvista
Addict
Addict
Posts: 967
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Colouring variables

Post 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.
- Windows 11 Home 64-bit
- PureBasic 6.30 (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 8K monitor with DPI @ 300%
User avatar
STARGÅTE
Addict
Addict
Posts: 2280
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Colouring variables

Post 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.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
charvista
Addict
Addict
Posts: 967
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Colouring variables

Post 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...
- Windows 11 Home 64-bit
- PureBasic 6.30 (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 8K monitor with DPI @ 300%
SMaag
Enthusiast
Enthusiast
Posts: 364
Joined: Sat Jan 14, 2023 6:55 pm
Location: Bavaria/Germany

Re: Colouring variables

Post 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.
User avatar
charvista
Addict
Addict
Posts: 967
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Colouring variables

Post by charvista »

Sound interesting.
I am very optimistic about the evolution of PureBasic.
- Windows 11 Home 64-bit
- PureBasic 6.30 (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 8K monitor with DPI @ 300%
Post Reply