Little Purebasic Preprocessor - LPP

Share your advanced PureBasic knowledge/code with the community.
User avatar
Blue
Addict
Addict
Posts: 868
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Post by Blue »

Little John wrote:Hi all,

now there is a new version, which can handle include files!
Please look at the first post in this thread.

Thanks for your attention, Little John
Nice to see that you're still sweating at the drawing board, Little John.
I'll give your most recent version a spin, as soon as I have some time to breathe.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

Hi Blue,

thanks for your message. Now there is version 0.60 hot off the press. ;-)

Best regards, Little John
somic
User
User
Posts: 66
Joined: Sun Jun 29, 2008 9:11 am
Location: Italy
Contact:

LPP (or LLP)

Post by somic »

Great code!!!
Now I see some more light...

Thanks a lot to all of you.

I feel the difference between:

Code: Select all

fSuccess = WriteFile_( 
         hPipe,               ; handle To pipe 
         pchReply,            ; buffer To write from 
         cbReplyBytes,        ; number of bytes To write 
         &cbWritten,          ; number of bytes written 
         #NULL);              ; not overlapped I/O
and

Code: Select all

fSuccess = WriteFile_(hPipe, pchReply, cbReplyBytes, &cbWritten, #NULL)
Regards,
Somic
somic
User
User
Posts: 66
Joined: Sun Jun 29, 2008 9:11 am
Location: Italy
Contact:

Post by somic »

Little John,

thank you for the great work.

In my system your preprocessor don't remove the $LPP directive from the ouput (~Lpp_) Include files.

This creates problems to the compiler when the include file has the $LPP directive. Compiled alone is OK but as Include gives error at the first line.

I've added some code at line 672, to work around it but I'd like to have your advise on it.

Code: Select all

                    WriteStringN(outFileID, line$, format)   ; Write line; 
to

Code: Select all

                If UCase(Left(line$, 4)) = "$LPP"                  ; remember $LPP must be first line
                    WriteStringN(outFileID, ";"+line$, format)     ; comment $LPP directive
                Else
                    WriteStringN(outFileID, line$, format)   ; Write line; 
               EndIf
I'm I correct?

Regards,
Somic
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

Hi somic,

thanks for your interest in this tool, and for your kind words.
I'm very sorry that I obviously didn't see your message when you posted it. Today, I stumbled across it by chance.
In my system your preprocessor don't remove the $LPP directive from the ouput (~Lpp_) Include files.

This creates problems to the compiler when the include file has the $LPP directive.
The $LPP directive is supposed to be used only in the main source code file, not in any include file.

Regards, Little John
somic
User
User
Posts: 66
Joined: Sun Jun 29, 2008 9:11 am
Location: Italy
Contact:

Post by somic »

I see.

But I've problems with my several and various include files and then, if you don't mind, I will keep the my copy of the code modified.

Thanks again,
Regards,
Somic
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

Hi somic,

no problem. You are welcome!

Regards, Little John
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Little Purebasic Preprocessor - LPP

Post by blueznl »

Duh, Little John, I never gave you credit for the multiline idea, as I used it in CodeCaddy :oops:
Last edited by blueznl on Wed Mar 03, 2010 10:48 pm, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Little Purebasic Preprocessor - LPP

Post by Little John »

blueznl wrote:Duh, Little John, I never gave you credit for the multiline idea, as I used it in PureBasic :oops:
Hi blueznl,

no problem at all. However, I'm afraid I don't understand ( well, that's quite normal :-) ).
Or do you mean "... used it in Code Caddy"?

Anyway, I stole the idea from QBasic, which I had used temporarily about 20 years ago.

Regards, Little John
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Little Purebasic Preprocessor - LPP

Post by blueznl »

Yeah, I meant CodeCaddy... it's late and I'm tired, so starting to make mistakes...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
RoySAC
New User
New User
Posts: 5
Joined: Mon Jan 11, 2010 8:13 pm
Location: Fresno, CA
Contact:

Re: Little Purebasic Preprocessor - LPP

Post by RoySAC »

It's a shame that such feature is not already build-into PB! The thing is that it does not have to be line separator at all. JavaScript allows multi-line commands without jumping through any hoops. The processor simply realizes that there is more to come and checks the next line... returning an error, if there isn't.

Thanks for the tool. The PB folks should send you a present and put something like it into their interface by default (and without the need for "$LPP" at the beginning of the code :) ). Adding comments to procedure parameter is one place where it is hard to live without a multi-line command option, add also the fact that if you inherit structures from one object to another, PB still requires to provide the whole chain to be able to access the final element.

Code: Select all

Structure BLAH
 field1.i
 field2.f
EndStructure

Structure BLUB
 ID
 Blahs.BLAH
EndStructure


Structure BLUBBER
  ID.i
  Blubs.BLUB
  Name.s
EndStructure

Global Dim Blubbers.BLUBBER(10)
Global Dim MoreBlubbers.BLUBBER(10)

;required
MoreBlubbers(a)\ID = Blubbers(a)\ID
;...
MoreBlubbers(a)\Blubs\ID = Blubbers(a)\Blubs\ID
;...
MoreBlubbers(a)\Blubs\Blahs\field1   =  Blubbers(a)\Blubs\Blahs\field1
;...

;not possible
MoreBlubbers(a) = Blubbers(a)

;... not to mention

MyProc(Blubbers)
Procedure MyProc(WorkBlubbers) ;= like "ByRef" in VB to pass along whole object for processing
...
EndProcedure
All those things keep code shorter, but that's also unavailable, so touting that a multi-line feature is not needed for "clean" PB code is hypocritical.
The commenting on individual Procedure paramters still remains though, regardless how "clean" your code is. Nothing beats "THIS ; <== IS FOR THAT" when it comes to readability!

Thanks again for the Editor add-on!
Cheers!

Carsten aka Roy/SAC
--------------------------
[web] - [blog] - [contact]
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Little Purebasic Preprocessor - LPP

Post by Demivec »

@RoySAC: PB includes some of the features you desire.

Code: Select all

;this is allowed since v4.40
MoreBlubbers(a) = Blubbers(a)

;Structured parameters can be handled in at least two ways:
;  the first is for arrays
MyProc(Blubbers())
Procedure MyProc(Array WorkBlubbers.BLUBBER(1)) ;= like "ByRef" in VB to pass along whole object for processing
  ; ...
EndProcedure
  
;  the second is for a single structured element
MyProc(a.BLUBBER) ; or also MyProc(Blubbers(1))
Procedure MyProc(*WorkBlubbers.BLUBBER) ;= like "ByRef" in VB to pass along whole object for processing
  ; ...
EndProcedure  
I agree with the comments regarding multiline commands and using comments with them. I'm keeping hope alive. :wink:
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Little Purebasic Preprocessor - LPP

Post by Little John »

Hi,

a happy new year for everybody! :)

I just posted the new version 0.61 (please see first post of this thread).
The main improvement is support for #PB_Compiler_FilePath in Include statements.

Rgads, Lttle John
Post Reply