Little Purebasic Preprocessor - LPP

Share your advanced PureBasic knowledge/code with the community.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

I've posted a new version, the changes are mentioned in the comments at the beginning of the source code.
The next version of the program hopefully will be able to handle include files. :D

2Rook:
Thanks! :-)

2PB:
I see. In the code on the picture that you posted, the line continuation works. It's just the syntax coloring that is not correct. I don't know how to change that.

Regards, Little John
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I know it works, but the lack of proper coloring bothers me. :) I know it's hard
to fix, because I've tried too with my own code. Turning off syntax coloring solves
it, but that defeats the purpose. There has to be a way, though. I feel only Fred
would be able to do it, with the IDE's own internal code.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I didn't think VB supported continuation of an open string, I thought you had to close the string to put the continuation in. Otherwise you are guessing white space and could confuse the system with a comment char that's in a string after the "_" char
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I didn't think VB supported continuation of an open string

Ah, you're right! :oops: I just installed it to test, and indeed I remember
now that I did have to do line continuations for strings just like this:

Code: Select all

Private Sub Form_Load()

    a$ = "Hello " _
    & "there"

    Debug.Print a$

End Sub
So, yeah, Little John's app does match Visual Basic perfectly:

Code: Select all

MultiLine on

a$ = "Hello " _
+ "there"

Debug a$
Thanks, Little John! :) Now Fred: match it internally! :twisted:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

2 PB and pdwyer:
I've now changed the code, so that continuation of an open string is no longer supported. That's really cleaner.
Thanks for discussing that issue!

Regards, Little John
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Question: you said the trigger can be before compile/run AND/OR before
create executable, but there's no way to set both. It's either one or the
other, which means you can either test your app in the IDE only (before
compile/run) or no testing in the IDE but create executables. Kinda makes
it a bit useless? Or did I miss something?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

PB wrote:Question: you said the trigger can be before compile/run AND/OR before
create executable, but there's no way to set both. It's either one or the
other, which means you can either test your app in the IDE only (before
compile/run) or no testing in the IDE but create executables. Kinda makes
it a bit useless? Or did I miss something?
You can set many triggers, use the same plugin and different names :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

How do I set a trigger? I've never used a plugin before
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> You can set many triggers, use the same plugin and different names :wink:

Image
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

pdwyer wrote:How do I set a trigger? I've never used a plugin before
In the IDE, choose from the menu "Configure Tools ...".
In the window that appears click at the [ New ] button.
Then there'll be an options window, which beside other
things allows to select an "Event to trigger the tool".

2PB:
Cool picture! :D

Regards, Little John
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

thanks
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Kurokaze
New User
New User
Posts: 1
Joined: Fri Jan 30, 2009 12:34 pm
Location: Germany (near Hamburg)

my version of Join-Lines

Post by Kurokaze »

I could not resist :wink: to add my part to this thread...as I started with PB a few days ago and looked at some (visible) syntax of it and then discovered that I would like to expand/add my features...

During the last 2 days I have created a "Join-lines" tool (can be used standalone and certainly also as plugin). it is a small exe (with about 517 KB) but i did not see an option here to attach it...perhaps someone can point me to such an option. The tool expects 1 mandatory parameter = the root file name to scan through (there are additional debug options...). It will scan through that file for $Multiline directives as in that starting example and act on such "joined lines" properly, creating a separated output file with "Pre_" prefixed to the original file name IF there were lines to join. If the file does not contain $Multiline directives and no lines to join, no output file is created.
The $Multiline drirective can be used repeatedly to switch to different join settings (default is "_").

The tool will process all embedded IncludeFile and XIncludefile directives recursively and will create one single large Pre_xxxxx.pb file while scanning for any join cases. By creating one "flat" output file I did not need to modify the "included files sources" and also swap the IncludeFile directives.

The tool seems to be fairly fast in executing....

OK, but this is only the starting point for this tool:

1) I check the IncludeFile / XIncludeFile directives - had to do it in any case - for more (!?) "parameters following the file name. If there are some, I keep them in an internal list and match those "call options" against $xxxxx = vvvvvv directives inside of the included file. When the included file is the scanned, I check alll source lines for words contained like " ...... $xxxxx ......" and in those lines I will repplace the option-name with its value...yielding some simply preprocessing substitution. The "vvvvvvv" is the "default value" if the IncludeFile directive does not provide a fitting option itself.

This processing allows to have two (or more) IncludeFile directives for the same include file creating DIFFERENT embedded sources easily. This may overlap a bit with PB Macro....EndMacro handling, but I discovered that this processing is "a bit limited" relative to my IncludeFile processing.

2) Now for the Macro directive :o
The normal directive is something like "Macro mmmm (p1, ... po=vvv)"
where first are some "mandatory" parms and the optional parms with default values. The Macro reference always has to be like "...... mmmm(c1,.... ) ...."

What I wanted is some "more relaxed syntax" (I am investigating in expanding PB to allow "local expansions" of its grammar for new syntactical elements (for specific features extensions). My first goal with the Macro is to allow a source line like
...... mmmm v1 .... o=vvv o=wwww .....
where the parameters for the macro are not needed and optional parms can be given in arbitrary sequence. A Macro reference inside of a source line is then complete, when all mandatory values are recognized and any possibly following word is not fitting a optional parm name "= vvv" value.

Internally I reformat the Macro definition statements to be PB syntax again and the ref-source-lines to have proper PB macro ref clauses. So far everything is "staying within PB" for the time being...

A very primitive example:

...
Macro Circle x=0 y=0 r=1
.... just call some 2D-painting with x, y, and r values
EndMacro
...
Circle r=12
...
Circle r=2 x=100 y=100
...

any source line can have any number of such (and normal) Macro refs.

Currently all that works - I did simple tests and therefore will have found only trivial errors. If I get an upload option, I will provide a ZIP with the exe, some readme and small examples.

Feedback :twisted: ???
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: my version of Join-Lines

Post by Little John »

Kurokaze wrote:I could not resist :wink: to add my part to this thread...
That's fine. Welcome to the forum!
Kurokaze wrote:During the last 2 days I have created a "Join-lines" tool (can be used standalone and certainly also as plugin). it is a small exe (with about 517 KB) but i did not see an option here to attach it...perhaps someone can point me to such an option.
[snipped a lot of text about Kurokaze's tool]
Kurokaze wrote:If I get an upload option, I will provide a ZIP with the exe, some readme and small examples.
This forum doesn't have an upload option for binary files. There are several such options on the internet, though. You can then post a link here to your uploaded file(s). However, I think e.g. the "General Discussion" section of this forum is a better place to talk about things like that, rather than the "Tricks 'n' Tips" section here.
Kurokaze wrote:Feedback :twisted: ???
I created this thread, because I wanted (and had been asked) to introduce my "JoinLines" tool. If you want people to give you feedback to your tool, please create a separate thread for it. Shortly mentioning your tool here is fine, but I'd appreciate it if the feedback and discussion about your tool is not in the thread about my tool.

Thanks, Little John
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

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
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

New version 0.50

- Pre-processed include files are not merged into a single file anymore.
So in case of a syntax error, the IDE now shows the correct line.
- Fixed some bugs.

Regards, Little John
Post Reply