FreeBASIC lexer

All questions regarding lexer highlighting schemes are discussed here...
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

FreeBASIC lexer

Post by Alexey »

Lexer was made today.
It is in "plugins / addon manager / install" list.
File types: *.bas *.bi.
It was tested on files from this project:
https://github.com/XusinboyBekchanov/MyFbFramework
Many of its files were tested to show correct syntax coloring, code-tree nodes, folding.
Code-tree shows all methods/properties/operators from single class in a single folder. E.g. root node "MyNamespace", next level node "MyClass" with its members "MyClass.something".

Must highlight all number notations (decimal/hex/octal/binary/float).
And string constants.
And comments (single line/ multi-line), nested multi-line comments (1 level nested) are ok.

Check the keywords list, is it correct (in .lcf file, find list with 'xor').
Check the std funcs list, it is very small list because I added only most common funcs (in .lcf file, find list with 'WLet').

I made several hacks for correct folding of "if..end if", to support "if ... then ..." without "end if". it may have bugs. Other blocks folding - also not sure it's ok.
Report here all bugs.
Attachments
fb3.png
fb2.png
fb1.png
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Hi. Could you extend your lexer to support QB64, too? It's also a BASIC dialect and very similar to FreeBASIC.

You could find the full list of QB64 keywords here:

http://www.qb64.org/wiki/Main_Page

And the latest $NOPREFIX change here:

https://www.qb64.org/portal/changelog-of-v1-4/

As QB64 is a modern continuation of Microsoft Quickbasic 4.5, it's not have as much advanced features as FreeBASIC. It's fairly simple.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

- QB64 don't have new folding rules? (current lexer has about 10 folding rules)
- you need only to highlight more keywords? It's very easy, ok
- $NOPREFIX needs lexer change? seems no. as before, all IDs are colored as ids, with underscore and w/o.
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Alexey wrote:- QB64 don't have new folding rules? (current lexer has about 10 folding rules)
- you need only to highlight more keywords? It's very easy, ok
- $NOPREFIX needs lexer change? seems no. as before, all IDs are colored as ids, with underscore and w/o.
Will you implement it with a new QB64 lexer or just extend the current FreeBASIC lexer? I think you should create a new QB64 lexer. I have checked both the QB64 and FreeBASIC wiki and found they have some real differences. I'm not yet explore the full QB64 so I can't answer your questions. I only used the QB 4.5 part of it and some of the new features they have introduced so far.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

I can make a new lexer, or expand the current lexer. new is needed when too many diff's. but what diff's? you told about missed keywords- it's very easy fix in current lexer.
if you need _new_ lexer, you need to tell me many major diff's, give links.
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Alexey wrote:I can make a new lexer, or expand the current lexer. new is needed when too many diff's. but what diff's? you told about missed keywords- it's very easy fix in current lexer.
if you need _new_ lexer, you need to tell me many major diff's, give links.
The two languages have their root in QB 4.5 so there are a lot of things in common. But I found their approach to implement modern features to be differ. In the future they will further divert. So maintaining an one for all lexer will be problematic in the future. A very similar example is: you have both the Modula-2 lexer and Oberon lexer, don't you? These languages are very similar why don't there is an one lexer for them all? Because they are different language, even though I could use the Modula-2 lexer to code Oberon without major problems. The same applies for QB64 and FreeBASIC. QB64 is more primitive compared to FreeBASIC. FreeBASIC has OOP, namespace,... QB64 has none of them. Mixing the two language would cause problem. As it will highlight the keywords of FreeBASIC on QB64 code (where said keywords not exist) or the other way around. It will be a real mess. It's cheaper to maintain two separate lexer for each of them. The QB64 one could just be a FreeBASIC lexer modified to suite QB64. At least it's what I think :)
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

>The same applies for QB64 and FreeBASIC. QB64 is more primitive compared to FreeBASIC. FreeBASIC has OOP, namespace,... QB64 has none of them.

so I need to know what to delete in primitive one. what folding rules. what keywords (to delete, to add). what code-tree items. etc. and I need some test QB64 test files.
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Alexey wrote:so I need to know what to delete in primitive one. what folding rules. what keywords (to delete, to add). what code-tree items. etc.
This wiki main page contains everything you need: http://www.qb64.org/wiki/Main_Page

Focus on these page:

http://www.qb64.org/wiki/Keyword_Refere ... phabetical

http://www.qb64.org/wiki/Keyword_Reference_-_By_usage

http://www.qb64.org/wiki/Syntax_Reference_-_QB64

There are more on the wiki main page. It's a complete reference for QB64.
Alexey wrote:and I need some test QB64 test files.
You could download the QB64 distribution here: https://github.com/QB64Team/qb64/releases/tag/v1.4

I'm using the lnx version. The samples programs are in qb64/programs/samples.
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Hi. Just to note that QB64 also uses the .bas and .bi extensions as FreeBASIC does. But most of the time I found people name their source file all uppercased, e.g: TEST.BAS, TEST.BI so the uppercased extensions .BAS and .BI should be recognized, too.
gh_origin
Posts: 16
Joined: 27.09.2020 09:30

Post by gh_origin »

Alexey wrote:>The same applies for QB64 and FreeBASIC. QB64 is more primitive compared to FreeBASIC. FreeBASIC has OOP, namespace,... QB64 has none of them.

so I need to know what to delete in primitive one. what folding rules. what keywords (to delete, to add). what code-tree items. etc.
Everything not mentioned on the QB64 wiki I noted above. I have already noted three wiki pages and I think you only need them but the whole wiki pages list are there on the wiki main page, too.
Post Reply