FreeBasic IDE-poseidonFB(Update 2024.10.02)

User projects written in or related to FreeBASIC.
Post Reply
Kuan Hsu
Posts: 606
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by Kuan Hsu »

shadow008 wrote: Sep 18, 2024 17:58 This feature could either be a built in default, or a toggle in the options, it doesn't matter to me.

Thoughts? Would it be too complicated/not worth it? I hope you can at least consider it. Thank you.
Please test https://www.mediafire.com/file/kowgygcu ... 31.7z/file, check if it fit your need~
shadow008
Posts: 107
Joined: Nov 26, 2013 2:43

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by shadow008 »

Kuan Hsu wrote: Sep 19, 2024 12:58 Please test https://www.mediafire.com/file/kowgygcu ... 31.7z/file, check if it fit your need~
Aha! It almost works! Though it seems to only assume the first generated type is the "correct" one. The parser appears to stop at the macro name, ignoring the parameters. If possible, just assume the parameters are also a part of the type and it should work. Here's a simple test case to illustrate what I'm doing:

Code: Select all

#macro GEN_TYPE(_NAME)
_NAME##_type
#endmacro

type GEN_TYPE(qwer)
	dim x as integer
end type

type GEN_TYPE(asdf)
	dim y as string
end type

type GEN_TYPE(zxcv)
	dim z as single
end type

dim a as GEN_TYPE(qwer)
dim b as GEN_TYPE(asdf)
dim c as GEN_TYPE(zxcv)

'a. [pops up x]
'b. [pops up x] (should pop up y)
'c. [pops up x] (should pop up z)

'To be clear, I don't care if the following doesn't work:
'dim x as GEN_TYPE( qwer ) 'Note the spaces around the parenthesis
'dim y as gen_type(asdf) 'I assume case insensitive is built in to the IDE, but even if it's not, I don't care if this doesn't work either
'var z = cast(typeof(GEN_TYPE(zxcv), ...) 'I don't care about var assignments even with explicit casting either
Kuan Hsu
Posts: 606
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by Kuan Hsu »

shadow008 wrote: Sep 20, 2024 3:00 Aha! It almost works! Though it seems to only assume the first generated type is the "correct" one. The parser appears to stop at the macro name, ignoring the parameters. If possible, just assume the parameters are also a part of the type and it should work.
Yes, it should be works, but I need fix a lot of code to do, because in my original design, the type attribute of parsed node is store as TYPE (PARAMETERS_STRING), poseidon need split the attribute to get TYPE and PARAMETERS_STRING by open parentheses, in another word, the TYPE is without any parentheses in design.

In new case, I need change the split-rule or add a new parameter attribute in parsed node class(I prefer this one)

The declare variable parse rule need change:
dim as GEN_TYPE(qwer) a ' tokens is: Tdim Tas TIndentifier TopenParen Tidenifier TcloseParen Tidenifier
Original : A veriable, but after first TIndentifier(type name) should be TIndentifier also not TopenParen(no variable name start at open parenthese), Illegal!

dim as GEN_TYPE(qwer) a ' tokens is: Tdim Tas TIndentifier TopenParen Tidenifier TcloseParen Tidenifier
Fixed Mean: A veriable, type is TIndentifier TopenParen Tidenifier TcloseParen, name is Tidenifier

dim as GEN_TYPE(qwer)tail a(10) ' tokens is: Tdim Tas TIndentifier TopenParen Tidenifier TcloseParen Tidenifier Tidenifier TopenParen Tnumber TcloseParen
Mean: a bit complicated......

I never used Concatenation Macro before( QB hasn't, D hasn't, I don't like C so I use D ), it's a part of preprocessor, maybe I should do the parse the preprocessor and replace the tokens, but I don't want to Implement it in poseidonFB

Let me think if there is a better way or not, for now I'm sure I'll add a special option if i done this work... :D
demosthenesk
Posts: 254
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by demosthenesk »

Is it possible to put a breakpoint in a line from IDE ?

i think that this it was possible in earlier versions but not now...

i think i moved the mouse pointer at the beginning of line and with left click i put a red disc-circle before line number...

do i remember wrong ?
i use Night theme color...
demosthenesk
Posts: 254
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by demosthenesk »

demosthenesk wrote: Sep 23, 2024 20:27 Is it possible to put a breakpoint in a line from IDE ?

i think that this it was possible in earlier versions but not now...

i think i moved the mouse pointer at the beginning of line and with left click i put a red disc-circle before line number...

do i remember wrong ?
i use Night theme color...
as i see now i can place a Bookmark not a Breakpoint...
what is a Bookmark ?
shadow008
Posts: 107
Joined: Nov 26, 2013 2:43

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by shadow008 »

Kuan Hsu wrote: Sep 23, 2024 2:56 Let me think if there is a better way or not, for now I'm sure I'll add a special option if i done this work... :D
If I had a D compiler I might attempt to implement this myself (but I don't and don't know D either), but I looked over the parser and the best I can come up with might look like this (in pseudo code):

parserFB.d around line 544 in getVariableType:

Code: Select all

...	
case TOK.Tidentifier:
	string _type;
	//Do some special parsing if the token is a known macro.
	//And maybe keep it behind an option you can turn on?
	if( TOK is MACRO OR DEFINE ANDALSO parseMacroTypesOption is true) //Does the parser know if it's a macro/define at this point?
	{
		_type ~= token.identifier; //Start by appending the macro name
		while( next().tok == TOK.Tcomma )
		{
			//Append each argument as-is
			//Maybe have to remove whitespace too, but I'm not sure?
			_type ~= token.identifier;
			parseToken( TOK.Tidentifier );
			//Skip over the comma or something
			parseToken( TOK.Tcomma);
		}
	} // Do normal processing
		while( next().tok == TOK.Tdot )
		{
			_type ~= token.identifier;
			parseToken( TOK.Tidentifier );
			_type ~= token.identifier;
			parseToken( TOK.Tdot );
		}

		if( !_type.length ) _type = token.identifier;else _type ~= token.identifier;
	}

	return _type;
...
My guess (it really is only a guess) is that this will allow the "_type" to turn to something like "GEN_TYPEqwer". Perhaps it may need a unique identifier or something so maybe also add a prefix so it turns into "_macroID123GEN_TYPEqwer" or something.
That said, I only spent about 30 minutes looking at the code, so I'm probably completely naive as to other changes needed.
Kuan Hsu
Posts: 606
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by Kuan Hsu »

shadow008 wrote: Sep 24, 2024 14:48 My guess (it really is only a guess) is that this will allow the "_type" to turn to something like "GEN_TYPEqwer". Perhaps it may need a unique identifier or something so maybe also add a prefix so it turns into "_macroID123GEN_TYPEqwer" or something.
That said, I only spent about 30 minutes looking at the code, so I'm probably completely naive as to other changes needed.
As I said before, it need change the parse rule, please try and test:
https://www.mediafire.com/file/45flttsi ... 32.7z/file

Except for var z = cast(typeof(GEN_TYPE(zxcv), ...), the others should be OK.
But var z = cast(GEN_TYPE(zxcv), ...) is worked. ( To use CAST to convert datatype, is necessary used TYPEOF? So I didn't modified the CAST parse rule )
Last edited by Kuan Hsu on Sep 25, 2024 1:45, edited 2 times in total.
Kuan Hsu
Posts: 606
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by Kuan Hsu »

demosthenesk wrote: Sep 23, 2024 20:27 Is it possible to put a breakpoint in a line from IDE ?

i think that this it was possible in earlier versions but not now...

i think i moved the mouse pointer at the beginning of line and with left click i put a red disc-circle before line number...

do i remember wrong ?
i use Night theme color...
1st: Run Debug,( the debug dialog will bottom-up )
2nd: Ctrl+Left click the line margin or Right-click the line margin
The bp mark is a red-rect after line-number
demosthenesk
Posts: 254
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by demosthenesk »

Kuan Hsu wrote: Sep 24, 2024 16:54
demosthenesk wrote: Sep 23, 2024 20:27 Is it possible to put a breakpoint in a line from IDE ?

i think that this it was possible in earlier versions but not now...

i think i moved the mouse pointer at the beginning of line and with left click i put a red disc-circle before line number...

do i remember wrong ?
i use Night theme color...
1st: Run Debug,( the debug dialog will bottom-up )
2nd: Ctrl+Left click the line margin or Right-click the line margin
The bp mark is a red-rect after line-number
ok you put bp after run debugger.
i tried to put bp before running debugger
...
now works
thanks
Kuan Hsu
Posts: 606
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by Kuan Hsu »

demosthenesk wrote: Sep 23, 2024 21:25 what is a Bookmark ?
Marked the bookmarks, quick jump to the bookmark; check the toolbar:
Image
shadow008
Posts: 107
Joined: Nov 26, 2013 2:43

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by shadow008 »

Kuan Hsu wrote: Sep 24, 2024 16:49 As I said before, it need change the parse rule, please try and test:
https://www.mediafire.com/file/45flttsi ... 32.7z/file
Yes! This works, at least on single file source codes. It has some difficulties working with the entirety of my project (60+ files). I'll keep fiddling with it to see if I can get it working everywhere, but for now, this will suffice. Thank you!
Kuan Hsu
Posts: 606
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2024.09.09)

Post by Kuan Hsu »

OK, I still do some adjustments, I expect to commit an update this weekend, if you have any findings, please tell me, thanks~ :)

About multifiles issue, I found where the bug is and will fix it
https://www.mediafire.com/file/cky4antr ... 33.7z/file
Post Reply