HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jass Precompiler

12-07-2003, 07:59 PM#31
AIAndy
The multiple rows work now, but I could not get the % with large numbers to work, he just resolves the one-digit-number and adds the rest of the numbers as numbers.
He cannot differentiate between %12 and %1 with an added 2 (as number) anyway. So I suggest either a fixed number of digits or maybe put a % after the number too, so %12% would be replaced by column 12, %1%2 by column 1 with an added 2.
12-07-2003, 08:20 PM#32
Vidstige
How stupid.... 0_o

Should be fixed now. :ggani:
12-08-2003, 11:20 PM#33
Vidstige
If someone could tell me how to write this tokenizer in a simpler way I would be quite happy.
Code:
$/="EOF";
$"="] [";
@tokens = ();
do { @tokens = (@tokens, /\/\/.*?$|\s+|('.*?'|\".*?\"|\w+|<=|>=|<>|==|[,\(\)=<>\/])/smog);  } while <>;
my @tmp = ();
for ($i=0, $j = 0; $i < @tokens; $i++) { $tmp[$j++] = $tokens[$i] if $tokens[$i];} 
print "[@tmp]";
And yes, it looks like a mess, I know. :////
12-12-2003, 10:47 PM#34
AIAndy
How is the precompiler going ?
I have merged now the RoC and TFT common.ai using #IFDEF and it works fine :)
I already see lots of tables in the code and I'll start working on them after I release AMAI 1.9 (this weekend).
One thing I encountered that would be useful is to have a precompiler variable that resolves into the row number when including tables. It would be best if to that row number you could also add a number.
A suggestion to the syntax:
#INCLUDETABLE <table.csv>
set my_array[%ROW%] = %1
set my_other_array[%ROW+5%] = %2
#ENDINCLUDE

For the condition in the include table I mainly need equal and unequal and maybe and/or to have two conditions on an include (only if it is not too much work).

I see a lot of possibilities :)
Keep up the good work :D
12-13-2003, 03:16 PM#35
Vidstige
Code:
------------------------------------------------------
|
|     Jass Pre-parser version 0.0.8
|
|                 by Vidstige
|
|        see [url]http://www.wc3campaigns.com/forums/showthread.php?s=&threadid=38726[/url]
|
|     Usage:
|        C:\ejass\ejass.pl sourcefile [> destinationfile]
|
|     Example:
|        C:\ejass\ejass.pl extended_script.eai > script.ai
|        C:\ejass\ejass.pl extended_script.eai
|
|     Supported Directives:
|        #DEFINE var
|        #UNDEF var
|        #IFDEF var
|        #IFNDEF var
|        #ELSE
|        #ENDIF
|        #INCLUDE filename
|        #INCLUDETABLE <filename> #COND %1 eq "humans"   // eq == equals
|        #INCLUDETABLE <filename> #COND %1 ne "monster"  // ne == not equals
|             set MyArray[%ROW] = %1                     // %ROW == line number in table file
|             set MyOtherArray[%ROW + 5] = %2
|        #ENDINCLUDE
------------------------------------------------------
Hope this fits your needs Andy. Is there anyone else that have experimented with the precompiler?

I plan to start making syntactic shortcuts after I have made some serious rewriting of the code.

I believe that it's soon time to look into the syntax checking as well... I suggest that you use pjass until then, that's what I'm using myself... :gsmile:
12-13-2003, 04:00 PM#36
PitzerMike
I like it, keep up the good work!
12-13-2003, 04:50 PM#37
AIAndy
Good :)

One more thing: It would be nice if you could specify that the first row is ignored in the table. That way it can be used to store the names of the columns (that makes the table nicer). I guess that is not too hard to implement.
Syntax suggestion:
#INCLUDETABLE filename #IGNOREFIRSTROW #COND ...

The condition looks fine :D .
If it is not too hard, it would be nice to be able to have 2 or more such conditions connected with #AND (So I could select the units from the unit table that are of a certain race and not of a certain type. That would make a good way to create the attack group creation code from the unit table)
Ex.:
#INCLUDETABLE units #IGNOREFIRSTROW #COND %2 eq "human" #AND %3 ne "peon" #AND %3 ne "hero"
call AddToAttackGroup(%1)
#ENDINCLUDE
12-13-2003, 05:57 PM#38
Vidstige
Oops... forgot to post the program. 0_o

try
Code:
#INCLUDETABLE <units> #COND %2 eq "human" and %3 ne "peon" and %3 ne "hero"
     call AddToAttackGroup(%1)
#ENDINCLUDE
12-13-2003, 08:26 PM#39
AIAndy
I tried #INCLUDETABLE and it does not seem to work in the newest version.
The code:
#INCLUDETABLE StandardUnitsTFT.txt
This(%1)
#ENDINCLUDE
What I get is the unchanged code. When I use the 006 version I get the right stuff:
This(Name)
This(ARCHMAGE)
This(PALADIN)
This(MTN_KING)
This(BLOOD_MAGE)
This(BLADE_MASTER)
This(FAR_SEER)
...
12-13-2003, 08:39 PM#40
Vidstige
Quote:
Originally posted by AIAndy
I tried #INCLUDETABLE and it does not seem to work in the newest version.
The code:
#INCLUDETABLE StandardUnitsTFT.txt
This(%1)
#ENDINCLUDE
What I get is the unchanged code. When I use the 006 version I get the right stuff:
This(Name)
This(ARCHMAGE)
This(PALADIN)
This(MTN_KING)
This(BLOOD_MAGE)
This(BLADE_MASTER)
This(FAR_SEER)
...

Uhm... that is as expected... try using:
Code:
#INCLUDETABLE <StandardUnitsTFT.txt>
This(%1)
#ENDINCLUDE 
Hope that this wont cause to much trouble to change. The reason why <> is needed around the filename is to be able to have more freedom in what expression works in the condition. The condition is as of now not a jass condition but a perl condition. I might change this, but I had quite some trouble being able to evaluate the condition at all. emote_sweat

So, it should work if you use <StandardUnitsTFT.txt> in stead of StandardUnitsTFT.txt.
12-13-2003, 09:12 PM#41
AIAndy
I tested around with it and it works only when you have a condition now. That is no problem as you can have 1 as condition so it always evaluates to true.
The %ROW variable works but it would be good if it did not return the position in the original table but the one in the new table with only those where the condition evaluated true (I need it to have a number that increases by one for each row put in by includetable). Or even better leave %ROW as it is now and put in a new one for the new functionality.
Also the %2 are only replaced with the actual value for the first occurance in the condition so two not equal on the same column in an evaluation do not work.
12-13-2003, 09:51 PM#42
Vidstige
The condition bugs should be fixed... it's possible to leave out the condition and also possible to have test against the same column several times.

The will come another %ROW version shortly...

I am thinking of fixing all includes before version 0.1.0. This is what I believe need to be fixed about includes until 0.1.0:

#IGNOREFIRSTROW in table.
#INCLUDEGLOBALS <file> // includes the globals part of given file
#INCLUDENONGLOBALS <filename> // inlcudes the non-globals part of given file
#INCLUDETABLE extension of %ROW and what else?
12-14-2003, 02:01 AM#43
silverdrake
Quote:
[i]Originally posted by Vidstige [
Hope this fits your needs Andy. Is there anyone else that have experimented with the precompiler?

I plan to start making syntactic shortcuts after I have made some serious rewriting of the code.

I believe that it's soon time to look into the syntax checking as well... I suggest that you use pjass until then, that's what I'm using myself... :gsmile: [/b]


I've been using the precomipler as well, to seperate files with the #include functionality. So nice not to have 2K-line files. I also added some shortcuts for assignment statements, i can post the code if you want to see it. As for syntax checking, personally I think this is low priority, pjass is good enough.
12-14-2003, 11:13 AM#44
AIAndy
The condition is printed in 008b (probably from debugging). I removed that line and it worked fine :)
Leaving out the condition and having multiple conditions on the same column both work.
12-15-2003, 03:51 AM#45
Vidstige
Now I've removed the same line as well...