mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Issue #2.
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
if (!isServer && player != player) then { // wait until player is on the server
|
||||
waitUntil {player == player};
|
||||
};
|
||||
|
||||
_getunit = _this select 0;
|
||||
_file = _this select 1;
|
||||
|
||||
if (!isNil _getunit) then { // unit exists?
|
||||
_unit = objNull;
|
||||
call compile format ["_unit = %1", _getunit];
|
||||
|
||||
if (local _unit) then { // test if local (player character)
|
||||
try {
|
||||
[_unit] execVM _file;
|
||||
}
|
||||
catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
if !isServer && player != player {
|
||||
waituntil(player == player);
|
||||
}
|
||||
|
||||
var _getunit = select(_this)(0);
|
||||
var _file = select(_this)(1);
|
||||
|
||||
if !isNil()(_getunit) {
|
||||
var _unit = objNull;
|
||||
call()(compile()(format()("_unit = %1", _getunit)));
|
||||
|
||||
if local()(_unit) {
|
||||
try {
|
||||
execVM(_unit)(_file);
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
waituntil(x = x+1; x < 100);
|
||||
var array = [1, 2, 3];
|
||||
var x = array[0];
|
||||
|
||||
if timeIsOver {
|
||||
exitwith {
|
||||
foo();
|
||||
bar();
|
||||
}
|
||||
if array[1] == 2 {
|
||||
foo();
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
var x = 1;
|
||||
var y = 3;
|
||||
|
||||
func foo(x, y) {
|
||||
return x+y
|
||||
}
|
||||
|
||||
hint()(format()("%1", foo(x, y)));
|
||||
@@ -1,15 +0,0 @@
|
||||
if (!isServer&&player!=player) then {
|
||||
waitUntil {player==player};
|
||||
};
|
||||
_getunit = (_this select 0);
|
||||
_file = (_this select 1);
|
||||
if (!(isNil _getunit)) then {
|
||||
_unit = objNull;
|
||||
call (compile (format ["_unit = %1", _getunit]));
|
||||
if ((local _unit)) then {
|
||||
try {
|
||||
_unit execVM _file;
|
||||
} catch {
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -1,7 +1,5 @@
|
||||
waitUntil {x=x+1;x<100};
|
||||
if (timeIsOver) then {
|
||||
if (true) exitWith {
|
||||
array = [1,2,3];
|
||||
x = (array select 0);
|
||||
if ((array select 1)==2) then {
|
||||
[] call foo;
|
||||
[] call bar;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
x = 1;
|
||||
y = 3;
|
||||
foo = {
|
||||
x = _this select 0;
|
||||
y = _this select 1;
|
||||
return x+y;
|
||||
};
|
||||
hint (format ["%1", ([x, y] call foo)]);
|
||||
@@ -420,6 +420,12 @@ func parseIdentifier() string {
|
||||
name := get().token
|
||||
next()
|
||||
output = "(" + parseFunctionCall(false, name) + ")"
|
||||
} else if seek("[") {
|
||||
output += "("+get().token
|
||||
next()
|
||||
expect("[")
|
||||
output += " select "+parseExpression(false)+")"
|
||||
expect("]")
|
||||
} else if accept("!") || accept("-") {
|
||||
output = get().token
|
||||
next()
|
||||
|
||||
@@ -129,6 +129,13 @@ func TestParserWaitUntil(t *testing.T) {
|
||||
equal(t, got, want)
|
||||
}
|
||||
|
||||
func TestParserArray(t *testing.T) {
|
||||
got := getCompiled(t, "test/parser_array.asl")
|
||||
want := "x = [1,2,3];\ny = (x select 1);\n"
|
||||
|
||||
equal(t, got, want)
|
||||
}
|
||||
|
||||
func getCompiled(t *testing.T, file string) string {
|
||||
code, err := ioutil.ReadFile(file)
|
||||
|
||||
|
||||
2
test/parser_array.asl
Normal file
2
test/parser_array.asl
Normal file
@@ -0,0 +1,2 @@
|
||||
var x = [1, 2, 3];
|
||||
var y = x[1];
|
||||
Reference in New Issue
Block a user