Link to the english version of DBPre:
http://www.thequest03.de/DBPre_RC1_english.rar
Hi everybody,
something I always missed in DarkBASIC Pro, was a descent (c-style) preprocessor, so I recently decided to write my own.
I'm finished with RC 1

.
It works mostly exactly like it's gnu-c-counterpart, i.e. everyone who has already worked in C with it's preprocessor, should have no problems using this in DarkBasic.
In fact, it is written on the basis of the following documentation (
http://tigcc.ticalc.org/doc/cpp.html).
There might be a few exceptions though and some things are just not supported.
Here is the complete feature-list of things supported and tested:
Quote: "
1. macros and inline-functions may be defined/undefined/redefined
#define MIN(X,Y) (((X) < (Y))*((X) - (Y)) + (Y))
print MIN(2,3)
#undef MIN
2. testing, if a given macro is defined and (of course) performing actions (#ifdef, #ifndef, #if, #else, #elif, #endif)
#define DEBUG
do
#ifdef DEBUG
print "Health: ", getHealth()
print "Active: ", isActive()
`...
#else
doKi()
findPath()
`...
#endif
loop
3. testing, if a given (constant) expression has a certain value or fulfills a certain equation
#define BUFFERSIZE 1024
#if BUFFERSIZE*(2+BUFFERSIZE)^3 < 6
doStuff()
#endif
4. compute constant expressions at compiletime (in doubled precision)
#define ADD(a,b) (a+b)
print [ADD(1,2)-3^4/5]
5. get the actual line and file (__LINE__, __FILE__)
print "This is line ", __LINE__, " in file ", __FILE__, "."
6. get the time, date and currently parsed function (__TIME__, __DATE__, __FUNC__, __TIMEDATE__)
print "Compile-Time: ", __TIME__, " on ", __DATE__, "."
7. get ASCII from character (e.g. 'a', 'b', etc.)
for i = 'a' to 'z'
print chr$(i);
next i
8. use control-characters in strings ("Hello\nworld")
Print "This\nis\na\ntest\n\nShe said, \"How are you?\"\n"
Wait key
9. concatenation of tokens (##)
#define CONCAT(A,B) A ## B
CONCAT(foo, bar)
10. stringification of tokens (#)
#define WARN_IF(EXPR) _
if (EXPR) then print "Warning: ", #EXPR
WARN_IF(x = 0)
11. special #options for setting values in the setup.ini (see changelog at the bottom)
#define DEBUG
#ifdef DEBUG
#option debug
#else
#option release
#endif
time = timer()
i = 0
while i < 10000000
inc i
endwhile
print timer() - time
wait key
12. dbp-comments are removed (we all know, the dbp-compiler has had its issues with ignoring comments - now they just don't pass through)
"
Since the preprocessor will necessarily change the sourcefiles formatting, the error lines given by the compiler, will not match anymore.
This problem has been taken care of, by using hooks to inject code into the original compiler, which automatically transform "wrong" lines into error lines (and file) matching your code.
This feature has been testet with the standard-IDE, BlueIDE and jaPROe and seems to work for all three.
I expect that to work with every IDE now and in the future, because it simulates compiler-behaviour.
Installation is simple.
Simply copy the files included in the above archive into the DBP-compiler-dir and execute the DBPre.exe.
It'll then rename the original compiler into "compiler.exe" and itself into "DBPcompiler.exe".
In addition, a keyword-file called dbpre.ini will be created in the editorkeywords folder and a file called "dbpre-uninstall.bat" in the original compiler folder.
To uninstall DBPre, simply doubleclick that file and everything is, as it was before (i.e. no registry-entry or something like that).
This software will in no way harm your computer or DBP, nor will it "call back" to me, the creator (if you don't believe me, you may wait until the source is open to compile it yourself).
I recommend you to read the documentation for the GNU-C-Preprocessor in advance.
Nearly everything should be supported, with a few exceptions.
If something is supported, but does not work as described in the manual, I consider it a bug and would be pleased to hear from you soon

.
If something is not supported, but you would like to have it supported for the final release, you may email me or just write that into this thread as a suggestion (email-address is: d-man ät thequest03.de).
With the final release, I intend to also release the (C-) source code, so please help me by testing this tool to have a stable first release!
Changelog from public beta to RC1: (public to the german board)
Quote: "
Version 1.0.0.587
- first non-beta release -
ADDED
* support for the "defined"-Keyword in evaluations for quickly determining wether a given macro is defined or not
* support for the predefined macro "__FUNC__", which returns the name of the currently parsed function
-> top level is called "$main$"
* support for the stringification operator "#", which stringifies macros and words
-> ensured, that it only works in macros, not normal source
-> also ensured, that internal quotes are properly replaced
* support for the concatenation operator "##", which connects two words in the final sourcecode
-> ensured, that it only works in macros, not normal source
* support for the compiler directive "#option" for specifying preprocessor options
-> added option "mergelines", which enables global line concatenation, when _ or is found at an end of line
-> added option "nomergelines", which disables global line concatenation (default)
- concatenation in definitions of macros is always active
-> added option "release", which disables error-checking in the final exe and no local temp folder at execution time
-> added option "debug", which enables additional error-checking such as array boundary checks and local temp folder at execution time
* multilanguage support
-> supported languages at the moment are german and english
CHANGED
* introduced warnings, which do not stop the compile process, but may show possible errors
* all comments are now ignored globally, even in macro definitions
* if non constant identifiers are found in an constant evaluation, a warning is thrown and the identifier is assumed to be zero
* leading and trailing whitespaces in parameters are now ignored - whitespaces between words or parameters are still recognized
FIXED
* error was illegally thrown, when identifier used in evaluations, which would normally have been defined, but where turned off through conditional compiletime
* replacement of inline macro parameters was incorrectly done, if the first part of parameter content was the name of any parameter
* small memory leak, when new layers in symtab were created (strdup was accidently called twice and one pointer got lost)
* compiler reported error lines are now corrected automatically by the preprocessor
* error lines reported by the preprocessor should now be more accurate
* preprocessor errors now simulate compiler behaviour, hopefully causing 100% compatibility with all DBP-IDEs
* negative numbers in expressions are now valid, even in exponents
* parameter stack is now only limited by available memory instead of static 100 entries (I wonder if anybody needs more than 100 parameters though)
"
I know, there might be some things unclear, but I try to write the documentation for the english version ASAP

.
Feedback would be greatly appreciated!
God is real, unless declared integer.