| 11-29-2003, 06:47 PM | #1 |
Jass isn't the best or prettiest of languages and many have been confused and/or discusted by it's limits and strangeness. What can then be done to make it possible to use jass with less annoyance? The Jass Challenge (se other thread here in AI/Jass Vault), tries to take care of the problem with the lack of datastructures. But there are also other problems to take care of; like how do we easily include and use developed library functions in our own scripts? AIAndy has already suggested that a pre-processor that supports the use of higher level language construct (like structs) would be useful - and I fully agree. My intention is to start creating such a pre-processor and I am wondering what functionality coders want from it. |
| 11-29-2003, 07:06 PM | #2 |
Can you explain what this pre-compiler will do? I don't get it, I just voted for that which I generally prefer. |
| 11-29-2003, 07:21 PM | #3 |
Good point KaTTaNa. The purpose of a pre-processor is that it reads in source code, make some manipulation and writes it to a new file. The manipulation bit could consist of automagic inclusion of pre-made functions (to avoid copy/past) and/or conversion from some extended syntax to the standard syntax. The task of the precompiler in our case is that it shall prepare our sourcecode for the inclusion in a map file. It shall also try to make it as easy as possible to get our code in the target map. After all, coders are supposed to be lazy... 8)) |
| 11-29-2003, 08:41 PM | #4 |
A struct would be nice. And includes that can have parameters. And since the struct feature probably requires parsing of the code anyway, the syntax check could be included too. I think it depends a lot on how much effort you want to invest into this. A feature that converts external data files into code would be nice too (like it takes an external table and converts it into code that initializes an array with each column). That reminds me of an easier feature: #IFDEF like in C. Such a precompiler would be a very nice tool :D |
| 11-29-2003, 08:53 PM | #5 |
it would take a while to code im shure parsing text file can be long prosses as is. |
| 11-29-2003, 10:55 PM | #6 | |
Quote:
This is where perl comes in handy, with it's support for regular expression everything should be possible. :gsmile: The plan is to create: one translator that translates from any extended syntax to normal jass syntax, one linker that sorts out which functions is in what files and store them in one file, and a syntax checker. The translator will probably be created first, since I am totally disgusted with some of Jass' constructs, and the linker secondly, since I am almost as disgusted with having to copy and past all printing code in my ai scripts. But now I have to go and learn some more perl if ever anything should happen... The point with having several programs is that you shouldn't have to use all of them if you don't want to. ;) |
| 11-29-2003, 10:56 PM | #7 |
| 12-01-2003, 12:16 PM | #8 |
The first version of the precompiler will need perl installed on the system and have support for C-like #include statements (this is quite easy really). The features I am considering in the next version is automagic inclusion of needed code, which means that if your script call YourNiceFunction and YourNiceFunction doesn't exist in the scrip, then the precompiler will try to find it on disc and include it in the compiled file. Those of you wanting healthy C-ish syntax: which constructs in Jass are you most annoyed with? Is it having to write set, call, function or what? Speak up and your wish (if it's not to complex) might be included early. This parser/compiler will try to be as useful as it can and people having other products that want to communicate/integrate with it should speak up (for best results, that is). It will also try to be as useful as possible for AMAI. If there will be any class support in any current future relies heavily on the results from the Jass Challenge I suspect. If you want to prepare for the version version of the pre-thingie you should make sure you have perl installed ( http://www.perl.org/get.html ), or at least say which platform you want it compiled for (I am sure that it can be arranged somehow by someone). |
| 12-01-2003, 12:33 PM | #9 |
Some suggestions for the precompiler syntax: #DEFINE <varname> #IFDEF <varname> #ELSE #ENDIF These allow to put debug and standard version into the same file (or different versions). #DEFINE defines a precomiler variable. The code after #IFDEF is left out if the corresponding precompiler variable is not defined. #INCLUDE <filename.j> Puts the content of filename.j at that position, a possible global section of filename.j is put at the end of the global section of the precompiled file. Before being included filename.j is precompiled (#DEFINEs before #INCLUDE influence the precompilation of filename.j) #INCLUDETABLE <table.csv> set %1 = %2 #ENDINCLUDE The code in between is repeated for every row in table.csv and %x is replaced with the xth column of table.csv . Some examples: Code:
#DEFINE DEBUG
...
#INCLUDE natives.ai
globals
...
#INCLUDETABLE constants.csv
constant %1 %2 = %3
#ENDINCLUDE
...
endglobals
...
#IFDEF DEBUG
#INCLUDE debug.j
function Start takes nothing returns nothing
call DisplayToAll("Debug mode")
endfunction
#ELSE
#INCLUDE standard.j
function Start takes nothing returns nothing
call DisplayToAll("Standard mode")
endfunction
#ENDIF |
| 12-01-2003, 02:30 PM | #10 |
Here comes the first primitive version with support for: #DEFINE #UNDEF #IFDEF #IFNDEF #ELSE #ENDIF see AIAndy's post above for use. If you manage to start the program it will try to explain how you should use it. :gsmile: Don't forget to change .txt in the filename to .pl. |
| 12-01-2003, 03:44 PM | #11 |
I could not get the #IFDEF to work correctly. He always entered the #ELSE part. And it would be nice if you could make it possible to nest #IFDEFs |
| 12-01-2003, 07:36 PM | #12 |
Something I would find wonderful would be support for inlining. It could be very useful when creating multiplayer functions. Also, templates (for passing arrays to functions and the like) would be great (but pherhaps too much work). Classes and the like would be good but I don't think it'd be worth the effort. Another thing on my wishlist would be single global variable declarations in the middle of the script. Like: global integer aah = 5 global constant integer what = 10 EDIT: I may add that I also whole-heartedly support structures. And I believe that the syntax should be the same or similar to normal JASS syntax. |
| 12-01-2003, 08:28 PM | #13 |
If you find any bug please send me some code that doesn't work, but you think should work. I will look into the #ELSE problem Andy and I will probably fix support for nested #IFs soon too. |
| 12-02-2003, 07:57 AM | #14 |
I think I've managed to implement useable support for nested #IFDEFs now. Use clever indentation with the direktives at your own risk, say #DEFINE debug without any extra spaces or tabs. Don't complain before you removed all extra whitespace anyway. ;) @Peppar: I will look into the globals part when I implements more intelligent inclusion of files, as it is now it just include the given to the #INCLUDE directive without regarding if there are globals section or not. I am considering making it include just those function and other that it needs... I will consider inlining/macros. As it is now I will try to implement first what people yell about, has voted on and/or is relativly simple. |
| 12-02-2003, 03:39 PM | #15 |
Well, here is a test file that does not seem to work for me (and I can't see any extra spaces or tabs). The part after the #ENDIF is cut away. http://amai.wc3campaigns.com/test.eai http://amai.wc3campaigns.com/test.ai |
