It is currently Tue May 21, 2013 9:47 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: A preprocessed single source file with macros expanded
PostPosted: Wed Nov 16, 2011 12:27 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2238
Location: Italy
WHAT:

I would like an option to make the compiler generate a single source file (processing all the includes) and an option to expand the macros too.

WHY:

It would be nice to process the resulting file with some kind of tool (for various purposes) and then launch again the compiler on the resulting source. The macro expansion would be nice to simplify the parse of the source, since with macros you can generate code not easily "visible" unless you add to your parser the code to expand the macros too. Since PB do that already, would be nice to have him work for us.

Thank you.

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Wed Nov 16, 2011 10:20 am 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1565
Location: Germany
I remember a similar request where I already +1'd... Here:
viewtopic.php?f=3&t=40658


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Wed Nov 16, 2011 12:02 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2238
Location: Italy
Oh, I'm sorry, I missed that...

Thank you.


EDIT: Actually I even replied to that thread... eheheh :oops:

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Fri Mar 09, 2012 7:48 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1382
Location: Boston, MA
Not that this gets you there, but if you purposely compile your code with an error in a Macro, then the Macro is expanded in the 'Macro Error' Window. :wink:
It would be nice to see the final expanded code for lots of reasons already mentioned.

_________________
To understand recursion, you must first understand recursion. ~ unknown
I never make stupid mistakes. Only very, very clever ones. ~ John Peel


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Fri Mar 09, 2012 8:41 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2238
Location: Italy
skywalk wrote:
Not that this gets you there, but if you purposely compile your code with an error in a Macro, then the Macro is expanded in the 'Macro Error' Window. :wink:


Yes I knew it, it's a trick I use when I want to check if a macro is expanded the way it was intended to :mrgreen:

But thanks for the suggestion!

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Tue Jan 29, 2013 12:35 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2238
Location: Italy
Sorry to bring this up again, but is there some possibility this will be implemented in the "near" future ?
Not asking for a date... only if it is planned or if there is no hope :)

Because today I stumbled on another case where this feature would have been very useful.
I have to generate some documentation from a lot of sources, many includes, etc, all part of the same library. I have to write the program to extract all that info (present in the sources as comments) and generate a big file with all the documentation for any single procedure.

If this feature were here, I could generate a single big file with all inside and process just that one.
A lot easier.

It's only one of the *many* things that could be done more easily (or at all) with it, and probably the most mundane.

Thank you and please don't shoot me.

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Tue Jan 29, 2013 1:08 am 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1382
Location: Boston, MA
I'm also looking forward to this feature.
I'd like to scan this file for any unused declared variables or stray procedures that should not be included.
Searching 1 expanded file will be much easier. :wink:

_________________
To understand recursion, you must first understand recursion. ~ unknown
I never make stupid mistakes. Only very, very clever ones. ~ John Peel


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Tue Jan 29, 2013 1:32 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 222
Location: Ontario, Canada
@luis

While you're waiting, why don't you just write your own preprocessor? The PB macro facility is quite primative, so a few hours work should give you what need.

We use a simple text substitution macro facility in our code generator software. As I recall, it only took a couple of days to write.

_________________
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan


Top
 Profile  
 
 Post subject: Re: A preprocessed single source file with macros expanded
PostPosted: Sun Feb 03, 2013 10:06 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 2238
Location: Italy
@BorisTheOld

Because the macros are only one piece of the puzzle on the road to have a single file (see first post).
Because compilerif have so many possible conditions it can be tested against, and I should implement them all.

random example:

Code:
CompilerIf SizeOf(structurename) = 24
 IncludeFile #PB_Compiler_FilePath + "..\code\foo.pb"
CompilerElse
 IncludeFile #PB_Compiler_FilePath + "bar.pb"
CompilerEndIf


good luck

Because PureBasic is not immutable, so I would have to keep up with any new addition / variation to the above features.
But above all because Fred has access to all this already, he need to output the result, and any change would be automatically included for the next version.
For me it's not trivial and I would hate to spend the time to do this just to find it implemented in the next version (hence the naive question I asked again here... didn't have many hopes but not asking it it's a sure way to not have it answered).
In short, for me it's not "so worth" the effort, since I can do something else more useful for me in the meantime. Would I like it ? Yes. I want to do it myself ? No. Will I change my mind ? Depends on what I'm doing at a certain time. Would I shameless use the code from someone else ? Certainly and thankfully.

There are many routines to make "one single file from all the includes" already posted in the forum, but no one works AFAIK.

I still have hope to see it someday because this is not something only I would appreciate, can be really useful to make many interesting tools.

That's my answer :wink:

_________________
[ Home ] [ My PC ] [ New to PB ? ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye