• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

JASS Infinity

Status
Not open for further replies.
Working on a new tool for WE called JASS Infinity.


All precompiler statements are sent to Lua and are then translated into JASS code =).


Thus far, I've figured out how to read/write to wc3 map, extend Lua with c++, do Lua plugins with c++ in separate dlls, and parse out a language =).


Here is a preview for the language =P
$label = Lua var

#awesome = Unit.create('hpea')
#awesome.name = "awesome"
#awesome.goldCost = 60
local integer goldCost = $awesome.goldCost //awesome?
local integer getOutput = $crazyLuaFunction() //double awesome?

//T is a local constant in this case, accessible by both Lua and vjass as a map constant
list<T>
#if ($T == $INT) then
#else if
#end

static if T == INT
elseif
endif

Lua can access all vjass map constants via $
All vjass primitive constants are translated into map constants and they maintain scope!

debug keyword ->
#if ($DEBUG_MODE) then
writeline(jass)
#end


enum

#function print(a)
DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,$a)
#end

//watch me spam some code, make a print function in Lua ;D
#print("yo")
#print("omg")

struct extends array auto removes code
rewriting allocate or deallocate auto removes code

extends, :

multiple extension, no more super, use ClassType

Union: group of variables

foreach, uses first, last, end, next, prev
foreach (var in list) { }
foreach (var in list from list.first to list.last) { }
foreach (var in list from list.last to list.first) { }

for (auto i = 3; i != 6; ++i) { }

i++, ++i, etc

Smart polymorphism, only evaluate when run by a superclass

protected
public
private

readonly

modules with implement a(args)

auto null all handle locals that need nulling and auto safe return

smarter auto inlining (inline if it's a var or ref'd one time)

auto run blocks, no more stupid onInit
{ }

lambda expressions
ForGroup(hi, { code } -> bool )

static ifs -> Lua ifs (#elseif turns into #else if and #endif turns into #end)
all constants used in static ifs have $ put in front of them

ternary operator
bool? this : otherwise

fix '\\\\\\\\'

string = SubString(string, i, i + 1)
string[i .. i2] = substring(string, i, i + i2)
string.length


writing methods outside of structs that take custom pointers
void this.method(unit this) { }

real this.hp(widget this) { return GetWidgetLife(this) }
print(peasant.hp)

Lua

replace all \$ with $ inside of strings
replace all $ with str .. var .. str inside of strings


auto i = 3
integer i = 3

locals declared anywhere in function with scope
{ } in function is internal scope


void hi() {
{ int a; set a = 3 }
{ int b; set b = 6 }
}

function hi takes nothing returns nothing
local integer a
set a = 3
set a = 6
endfunction


scope A
public func

A::func


A() constructor
~A() destructor

new A()
delete A

void hi()
void hi(string s)
void hi(int i)
void hi(string s, int i)

modulo: 3%5

i = 3%5
i = 3 - 3/5*5
 
Last edited:
For the parsing and stuff, I'm using ANTLR with C Target =o. I really like it so far, a lot =). There is still a lot I need to learn with parsing though, I'm kinda noobish : \. I ended up designing a lot of the parsing in a naive way, so imma end up having to redo a lot. I found an example of c# grammar online, so I'll probably be studying that =).

I learned how poor my ways were when I started implementing other operators besides +, -, *, and /.
 
Just a note

JASS:
//outside
real widget.hp { return GetWidgetLife(this); }
void widget.hp = real { call SetWidgetLife(this, value); }
void widget.hp = real life { call SetWidgetLife(this, life); }

item unit.inventory[int index] { return UnitItemInSlot(this, index); }
void unit.inventory[int index] = integer { call UnitAddItemToSlotById(this, value, index); }
int unit.inventory.size { return UnitInventorySize(this); }
bool unit.inventory.add(item i) { return UnitAddItem(this, i); }
item unit.inventory.add(integer i) { return UnitAddItemById(this, i); }

bool int<int { return this < value; }
int int<<int { /*bit shift*/ }

//inside
real hp { return }
void hp = real { set }
int [index i][index i1][index i2] { return }
void [index i][index i1][index i2] = integer { set }
void test = int i, real r, string str { set }
test = { 5, 5.5, "hello" } //example of use

edit
more lambdas + function passing

JASS:
int test(int i(int), bool b) {
    if (b) {
        return i(5);
    }
    return i(0);
}

//run
int make(int i) { return i + 3; }
int k = test(make, true);
int k2 = test(int (int i) { return i + 5; }, false);

Output
JASS:
function test1 takes boolean b returns integer
    if (b) then
        return make(5)
    endif
    return make(0)
endfunction
function test2 takes boolean b returns integer
    if (b) then
        return lambda1(5)
    endif
    return lambda1(0)
endfunction

//run
function make takes integer i returns integer
    return i + 3
endfunction
function lambda1 takes integer i returns integer
    return i + 5
endfunction

//demo
integer k = test1(true);
integer k2 = test2(false);
 
Last edited:
Status
Not open for further replies.
Top