DP parser
This project is now dead.
Guestbook/Forum/Mailing list for discussion - Public access, so no need to register unless you want the messages emailled to you.
Mailing list for DP announcements - Read only, but public access.
News
3/7/2001 B: OK, I've uploaded what I have: two perl snippets, and a dba file (removed 19/7/2001, since it was for quats):
- dp-pretty.pl - This just makes the code prettyprinted for the forums. It only uses bold and italics, since those are the only codes I could find that worked in all the forums (most don't allow the ">font<" or ">code<" tags). It also replaces leading spaces with "&nbsp;" for correct indenting, and replaces ">", ":" and "&" characters with their metacharacters to prevent interpretation. Main problem with this is speed. Very slow, so I'm rewriting it.
- dp-indent.pl - Indents everything other than subroutines. Pleasantly fast, since it uses a different algorithm to the above (word-by-word, rather than character-by-character).
Still no full release of DP. Now there's no more need for quats, I'm feeling much happier. I'm no longer predicting a release date, because I've got embroiled in playing Anachronox. Once that's done, I'll come back to this...
The following is my wishlist of features for DP. Items in bold might make it into the first release. Items in Bolditalics almost definitely will. Items in gray italics are no longer to be implemented.
- In-code configuration - because I can't think of another way of setting the options easily. You'll configure it by putting "DP ..." lines in your code. Maybe a config file for default options later, but this comes first.
- Call DB - in any of its five modes (compile, make exe, make final, execute, and edit), or any parameters you want, or not at all.
- "Magic" indenting - checks your code by indenting/outdenting the loops. Optionally also indents backwards from "return" to the preceding label, if any. [Code for this part, albeit slow, is above]
- Forum formatting - creates a version of your source that will be correctly indented and syntax hilighted on these forums.[Code for this is above]
- Fix for DE's DEFINE bug - (defined variables all need spaces around them to work. Since the precompiler can only run after DE's precompiler, I'll make it just completely replace DE's DEFINE functionality. You'll need to turn it off in DE).
- Documentation - of course, I'll document it!
- Call another external program.
- Precalculate FOR loop values.
- Precalculate CASE statements.
- Wrappers for commands that don't give you an access fn (eg a wrapper for "scale object" would give you "get_object_scale()").
- WordCase setting - the option to specify variables and commands to lowercase/Title_Case/title_Case2/UPPERCASE, and defines, arrays, types, etc to the case they were defined as, or as any of the four main capitalisations. DP will modify all occurances to fit these settings. (thanks to Kona3D for this idea)
- A .reg file to correctly sort out file associations for darkedit. Low priority, will probably release separately.
- Brain Editor compatability. (Thanks to catadventurer for this suggestion). Low priority, though.
- Errors(E:) and warnings (W:) - DB's error reporting is not exhaustive, nor is it terribly clear. This is a major stumblingblock for newbies. I'd like to include warnings/errors like:
- "E: '-' used before/after a string. You cannot use '-' in string manipulation. This will cause DB to fail."
- "E: Bad lvalue - cannot assign to something with symbols in, or a constant"
- "E: One-line IF found without a NEXT condition."
- "E: Multi-line IF found with a NEXT condition."
- "E: no such command as elseif or elsif. Use 'else if' instead."
- "E: '.' used as string concatenator. Use '+' instead."
- "E: ':' found at the beginning of a line. This is illegal."
- "W: Nested FOR loops using the same variable name."
- "W: '-' in 'a-b+c' has 'a-(b+c)' precedence. Use brackets or place all subtractions at the end of the expression to avoid confusion."
- "W: integer division will return an integer. Multiply either side by 1.0 for a real result."
- "W: Nested FOR loops using the same variable",
- "W: May clash with future reserved word",
- "W: Goto/gosub into the middle of a loop"
- "W: Label never called"
- "W: variable never used"
- "W: definition never used"
- "W: remstart found with no closing remend"
- "W: remend found with no opening remstart"
- "W: 'NEXT' variable is different to the loop variable given in the 'FOR'."
- "W: Arguments to commands need to be separated by commas."
- "W: 'TEXT' command only permits strings concatenated by '+': you cannot use PRINT-like syntax."
- Fix DB's ": at beginning of line" bug - just remove them in the precompiler. Otherwise DB bombs out. (thanks to JoKeR(BW) for pointing this one out!) [Fixed (poorly, IMHO) in 1.09b2 - I might still stick this in as a warning.]
- A fix for DB's '^' bug - multiply both sides by 1.0 if they are int. [Fixed in 1.092b]
- A fix for DB's '-' bug 2 - Poss some kindof wrapper that subtracts a string from a string, or maybe just return an error. DB thinks "$str-$str" is valid, then it bombs out (I found this one while I was running tests trying to break it). [Less of an issue since 1.09, it only gives a runtime error now]
- A fix for DB's get angle z()=0 bug - replace pitch, roll, yaw and getangle(x/y/z) with replacements that work [Fixed in 1.093b - Thank goodness!].
- Matrix math functions - this is a free byproduct of fixing DB's "object angle z" bug. [But I'm not doing that anymore. I might provide these as a separate #INCLUDE-able lib, though, since I can see them being useful for filtering DB's world-matrices, and very handy if mesh deformations are ever implemented.]
- A fix for DB's '/' bug - multiply both sides by 1.0 if they are int. Default to off, because I guess sometimes you might want 1/2=0 functionality. [Naah, just have this as a warning.]
- A fix for DB's '-' bug - place () around any terms that are subtracted. Default to off, because some people might want 1-1+1=-1 behaviour. Sick weirdos. [Naah, just have this as a warning.]
Tech Notes
DarkEDIT
DarkEDIT doesn't let you define your own keywords (yet!), so I can't fix it's syntax hilighting, but this patch should fix everything else that's up with it (ie if you are getting bombed out of DB and DE just says "compilation successful", change this to call DB in edit mode).
DarkEDIT also doesn't let you define your own hotkeys (yet!) so this will have to replace the F5 compiler option. No loss, since it can do that as well, but it would be nice to have it with different keys doing different things.
Coding
Today I'll be writing mostly in perl. I'll release the perl source, and a compiled executable (using IndigoSTAR's "perl2exe": see www.perl2exe.com) for those who don't have perl installed.
Future plans
I'd like to get the error reporting to be extra-ultra-snazzy. I'm not quite sure how I'll be doing this. Ideally, I'd return a filename of errors to DE, which would display them in a window, and as you moved through the errors, it selected the line in your source. That's not gonna happen soon. At the moment DE can only cope with one error at a time, so I'm wondering whether to write the errors into a file and just send the most urgent to DE, or display them on the screen, or what. I also need ideas for other warnings and errors! Does anyone know the filename/syntax for DB's error reporting to DE?
If Guy or Lee implement any of this stuff directly in DE or DB, then I'll remove it from the next version to make it smaller. I'll try to make my code nicely commented, so if they want they can port my algorithms to whatever language they use.
I need other ideas for what people want to see in a well-behaved precompiler, and any improvements you can think of to the above wishlist (any extra warnings/errors, etc).
Legalese
I'm not sure on the legality of calling it DarkPARSER, so I'll call it DP. I wouldn't want to infringe on their potential namespace for trademarks, anyway.
Public License
The source and compiled executables for the current release of DP is released into the public domain.
You can sell it unchanged, as your own original work (but if you do this, people will laugh at you, and be rude to your mum at parties). Anyone can use it for any purpose, even if they work for Microsoft. I'm not going to bestow copyright and ownership of this on anyone, because I feel that is way too restrictive.
That's not to say I wouldn't appreciate any feedback or credit in your code that you care to give me. But I will not bestow ownership of this tool on anyone.
A public domain license may be classed by Microsoft as "potentially viral", along with the GPL, and so it is possible that this product, under their licensing terms, cannot be included with certain of their products.
Liability
This is currently a buggy early-alpha product, with all that the phrase implies. If you don't know what it implies, you shouldn't be coding anyway. Ignorance is no defence against bugs.