Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / DBP++: A Precompiler

Author
Message
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Mar 2007 18:03
I've been working on a precompiler for DBP which changes its syntax to be more akin to a curly bracket language (i.e. C/C++).

For example:



The same syntax is used for all conditional statements, so:



The precompiler also introduces a major change to the syntax of select statements:



The final advantage my precompiler brings is the 'Enum' statement. For those who've never encountered this statement in another language it allows you to list a group of constants which increase/decrease in value in order:



The 'Enum' statement takes the following format, where parts in []s are optional:



I'm fairly confient that my precompiler is bug-free, but I'm having some difficulty connecting it to the actual DBP compiler, so that's why I'm posting here. If anyone knows how to do this, I'd welcome their help (evil_grunger@*NOSPAM*hotmail.com).

As it stands you drag-n-drop your source file over the DBP++ exe and it will process it and OVERWRITE the original file, you'll then have to compile it manually via the DBP compiler, but I will get this fixed in later versions.

Enjoy!

~Heed my word hobags: Jism~

Attachments

Login to view attachments
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Mar 2007 18:18 Edited at: 3rd Mar 2007 18:18
To be honest I don't see the point in adding a slightly more complex syntax to an inferior language. Well, it's not exactly complex, I just don't see the point at all.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Mar 2007 18:27
Maybe you're right, I think it might be useful for some people who would like an introduction to curly bracket languages, however.

Still, I think the addition of enumerations and the changes my precompiler makes to the select syntax are quite nice additions - perhaps another version which makes these more inline with DBP's exisiting syntax would be better?

~Heed my word hobags: Jism~
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Mar 2007 18:47 Edited at: 3rd Mar 2007 18:47
The enum thing might be useful, and actually I like the syntax of the select statement. However, I assume you remember that break needs to be used to break out of each case? Else each case will run into eachother, which is only sometimes desired.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Mar 2007 18:51
I'm not quite sure what you mean Benjamin...

Using the example above:




The precompiler will generate the following code:



That's correct, right?

~Heed my word hobags: Jism~
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Mar 2007 19:18
Nope, if the break keyword isn't specified then a case should run into the next. At least, in C++ it's like this. The purpose of allowing this is when you want to group certain values into one block of code.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 3rd Mar 2007 19:58
Benjamin: I don't think that's the functionality of DBP's select blocks. For example, this only prints out "case 1":

In other words, it automatically breaks if a value is detected. Is that what you mean?

Killswitch: Accessing the dbp compiler is fairly easy. All you have to do is call the compiler with a project file as the arguments. It will then handle everything from there, and compile the project file.

I don't really see the use of this however, as this language should be BASIC, and not use curly brackets. The enum definition is nice though, and being able to do single line cases without having to use endcase is nice as well (you should still be able to use endcase, if you want).

You should probably have the syntax like this:


By the way, you should check out Nabil's precompiler manager in the WIP board, you might find it useful.

Who needs a signature?
Xarshi
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 3rd Mar 2007 20:19
why doesn't the enum thing have a variable assigned to it...

Like,in c++,its:


Thats just how I look at it...otherwise it makes no sense to me...

Hello
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 3rd Mar 2007 20:36
It doesn't really need one, as you aren't implementing instances of an enum, because it isn't really a type. It's just an easier way to declare constants.

Who needs a signature?
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Mar 2007 20:48
As Milkman says there isn't really a need for the enum to be assigned a variable.

~Heed my word hobags: Jism~
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 3rd Mar 2007 21:16 Edited at: 3rd Mar 2007 21:17
Quote: "Benjamin: I don't think that's the functionality of DBP's select blocks."

It's not.

Quote: "In other words, it automatically breaks if a value is detected. Is that what you mean?"

Not quite. Take this for example, in C:


It's not just a change in syntax, it's a slight change in functionality. Perhaps a little difficult to do.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 3rd Mar 2007 22:35 Edited at: 3rd Mar 2007 22:37
ENUM: i did a post on this and will include it as a main feature in DBPmC. also the bracked thing was an idea i had before :-P
ENUM Code: CodeBase Link
DBPmC PreCompiler: Forum Link

you might look into that.

-Nabil/BananaAcid- The Banana has you...?!
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Mar 2007 22:38 Edited at: 3rd Mar 2007 22:43
Quote: "To be honest I don't see the point in adding a slightly more complex syntax to an inferior language. Well, it's not exactly complex, I just don't see the point at all."


I agree with you in the sense that you almost have to learn a new language, but, it does look sexier than DBP.

Add OOP ploxx

Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 3rd Mar 2007 22:49
Apart from enums and OOP are there any useful features anybody would like to see a precompiler add to DBP?

@Nabil

But your's isn't avaliable for download

~Heed my word hobags: Jism~
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 4th Mar 2007 19:52
Lol, yeah you are right

-Nabil/BananaAcid- The Banana has you...?!
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 4th Mar 2007 21:33
Quote: "but I'm having some difficulty connecting it to the actual DBP compiler, so that's why I'm posting here. If anyone knows how to do this, I'd welcome their help"

Yeah, I can explain how to do that. I'll give the simple explanation here, and if you want the more detailed in depth explanation, such as seing the compiler status, getting error number lines, etc., just email me.

First, you create a valid .dbpro file(look at any for an example.) Then you collate all the source files into one large source file, and call this something like "temp.dbsource". You set what file this is in your .dbpro file. Once you have the .dbpro file and the source file, you just call the dbp compiler and pass the .dbpro file as the argument.

Having said all that, with the sudden interest in people building pre-compilers (yours, Milkman's and Nabil's) I think it's time to work on a plugin system for CodeSurge.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 4th Mar 2007 23:26
Killswitch: if you decide to have your precompiler call the compiler itself, I would suggest adding that functionality with a separate exe. This separate exe would take the project file from the ide as a parameter, copy the project elsewhere, call your core exe, and then call the dbp compiler. The reason for this is because it would still allow your precompiler to function as a plugin for a precompiler manager such as Nabil's or (soon to be) Hyrichter's.

Who needs a signature?
Chris Franklin_
17
Years of Service
User Offline
Joined: 21st Dec 2006
Location: Home
Posted: 5th Mar 2007 00:23
Quote: "Apart from enums and OOP are there any useful features anybody would like to see a precompiler add to DBP?"

How about anti aliasing?

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 5th Mar 2007 01:02
Quote: "How about anti aliasing?"

Since when has that been part of syntax?

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 5th Mar 2007 04:08
Quote: "How about anti aliasing? "


Le Rófl

Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 5th Mar 2007 06:22
Quote: ""How about anti aliasing?""

hehe. well that would actually go a bit towards the CStyle DEFINES

@hyrichter btw: i would be interrested on how you do ...
Quote: "...detailed in depth explanation, such as seing the compiler status, getting error number lines, etc..."


-Nabil/BananaAcid- The Banana has you...?!
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 5th Mar 2007 06:29
Nabil, here's a thread that explains a little about that, but Hyrichter would probably know a lot more:
http://forum.thegamecreators.com/?m=forum_view&t=56639&b=1

Who needs a signature?
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 5th Mar 2007 06:46 Edited at: 5th Mar 2007 07:09
@Milkman
thx, nice stuff. i read this and realize i am looking at some new api stuff...

another question: what is the theory behind source file line keeping when modifying using the precompiler and passing it to the compiler, so that the compiler returns the right code line?

@Milkan + Killswitch etc...
for an easier handling, can we agree on renaming and calling the original compiler 'compilerDBP.exe' for example ? would save me a lot of codelines for my manager and anyone elses manager..

-Nabil/BananaAcid- The Banana has you...?!
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 5th Mar 2007 07:04 Edited at: 5th Mar 2007 07:05
The theory is this: command stacking. With command stacking, you can preserve all the line numbers in all your source files, because you can stack an infinite number of commands on a single line
for example, this compiles:



So basically, whenever the precompiler needs to write a new command, it just stacks it on the current line. If it needs to delete commands, it just leaves the line blank.

Who needs a signature?
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 5th Mar 2007 07:11
uh..forgot to press the edit button.

ah ok. that is what i am currently doing ... lol... crap and i thought there would be some simple commands to modify the line number or so by some mem hack. *grin*

-Nabil/BananaAcid- The Banana has you...?!
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 5th Mar 2007 07:18 Edited at: 5th Mar 2007 09:06
but it makes it simple to create a mem hack would allow to paste own, more specific error messages, for example including error on a precompiler... are my thoughts going the right way?
I am paralized by this RTL-Teleshop infomercial crap @ TV......


Quote: "I'm fairly confient that my precompiler is bug-free, but I'm having some difficulty connecting it to the actual DBP compiler, so that's why I'm posting here. If anyone knows how to do this, I'd welcome their help"

yeah... i noticed. usually you use Shell32::shellExecute
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation, usually 'open'
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
e.g. ShellExecute(handle, NULL, path_to_anyfile_or_url, NULL, NULL, SW_SHOWNORMAL);
... i was trying to hook your exe but somehow had no chance to find any api call, nor any exe string. i allowed my self to decompile your exe. no i didnt save the code. still i cant find any file call. dunno how many jmps i stepped through.
dont know how that has to look in D for you. but i read something about importing std.c.windows.windows interface to access the WinAPIs.. maybe you solved this allready, anyhow hope it could help.

-Nabil/BananaAcid- The Banana has you...?!
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 5th Mar 2007 15:30
Mate, you needn't decompile my .exe, you can always ask for the source!

~Heed my word hobags: Jism~
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 6th Mar 2007 15:54 Edited at: 6th Mar 2007 16:01
hm thx. i was trying to find the command, but couldnt, so i was thinking about patching in memory. so needed to look at the compiled commands in assembler. sorry. thatswhy the work. but since i couldn't find anything i gave up checking it piece by piece.
so just lemme ask:
either you use a command to execute "compilerDBP.exe" (that would make my work a lot easier, since the originals name is DBPcompiler.exe), or i want to ask you if i can see your source.
what command are you using anyways?

EDIT:
btw: does you precompiler ignore the standart loops and enums if their syntax does not suit your requirements but the BASIC specifications ? or does your precompiler return an error ?

-Nabil/BananaAcid- The Banana has you...?!
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 6th Mar 2007 17:43
It returns an error, but I'll probally change this in light of peoples (very welcome!) suggestions.

At the moment my precompiler dosen't call the DBP compiler at all, so that's probally why you couldn't find anything...

~Heed my word hobags: Jism~
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 9th Mar 2007 07:22
just to mention:
its a "rule" to say that each "constant" in an enum statement should have an identifier infront of it that identifies the structure of which it is a "child"...

ENUM EmyEnum
meNil = -1
meZero = 0
meOne = 1
ENDENUM

enum names should start with an "E", but thats not important, the important part is, if you change the enum tags to constants, they might exist allready if someone didnt know about giving unique names (usually that doesnt matter in other BASIC languages, but wont work for the constant-translation). so you might add the enum name to this constants "EmyEnummeNil". check for all occurences of the enum type and rename them there accordingly to make sure. just an idea... well thats how i do it, so i thought i should share my thoughts...

-Nabil/BananaAcid- The Banana has you...?!
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 9th Mar 2007 08:41
But you don't need an identifier for the enum, as it doesn't really have a parent in this language (unless you've managed to implement that).

Who needs a signature?
Killswitch
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 9th Mar 2007 14:25
@Nabil

I think you're still misunderstanding what this enumeration does its NOT like enums in C++.

As about giving them unquie names in the precompiler I don't think this is nessacary either, people should know how and use the enum properly rather than trying to babysit them.

~Heed my word hobags: Jism~
El Goorf
18
Years of Service
User Offline
Joined: 17th Sep 2006
Location: Uni: Manchester, Home: Dunstable
Posted: 9th Mar 2007 22:26
as someone currently making a move form dbp to c++, i welcome this.

http://notmybase.com
All my base are not belong to anyone.
Nabil
18
Years of Service
User Offline
Joined: 19th Dec 2005
Location: Germany
Posted: 10th Mar 2007 16:41
@kill
hm, the idea was to provide a reference to how this works in basic. i wasn't realizing that you do not enable BASIC enums, neither changing compleatly to C++ enums.
but i like how your enums work. an enum/for hybrid.

-Nabil/BananaAcid- The Banana has you...?!
Hubdule
22
Years of Service
User Offline
Joined: 3rd Sep 2002
Location: Gundelsheim
Posted: 15th Mar 2007 09:18 Edited at: 15th Mar 2007 09:18
There's a preprocesseor project (made by D-Man) on the german DBPro forum for a while. If you're interested in somthing like that then you should download it here:

http://www.thequest03.de/DBPre_RC1_english.rar

Make a backup of you compiler directory then simply copy it to this dir and run it. The installation should be ready within seconds. I don't know if there's currently an english version of the manual but there's a german one with some examples. Maybe that helps you. The german manual is here:

http://en.dblounge.org/main.php?&site=tutorial&lpid=37

There's also some info about the source of that thing:

http://www.thequest03.de/DBPre_src/dbpre_src.html

and

http://www.thequest03.de/DBPre_src/dbpre_src.rar
It's a really nice tool I think. Hope you like it too.

Life is good!
Webmaster and Support for: http://www.fpscreator.de and http://www.darkbasic.de

Login to post a reply

Server time is: 2024-09-29 20:33:20
Your offset time is: 2024-09-29 20:33:20