mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Missing != operator, added test for all of them.
This commit is contained in:
8
ToDo.md
8
ToDo.md
@@ -1,7 +1,6 @@
|
|||||||
# ToDo
|
# ToDo
|
||||||
|
|
||||||
* ~~assign to returned values~~
|
* ~~assign to returned values~~
|
||||||
* special cases (like if ... exitWith, waitUntil {...})
|
|
||||||
* ~~sqf: ... sqf whitespace~~
|
* ~~sqf: ... sqf whitespace~~
|
||||||
* ~~solution for build in commands which do not require left values~~
|
* ~~solution for build in commands which do not require left values~~
|
||||||
* ~~pretty/minified printing~~
|
* ~~pretty/minified printing~~
|
||||||
@@ -11,3 +10,10 @@
|
|||||||
* ~~inline buildin function call -> foo(a)(bar(x)(y));~~
|
* ~~inline buildin function call -> foo(a)(bar(x)(y));~~
|
||||||
* ~~negative values e.g. -1, operator !~~
|
* ~~negative values e.g. -1, operator !~~
|
||||||
* ~~tokenizer splits commands like "format" -> for, mat~~
|
* ~~tokenizer splits commands like "format" -> for, mat~~
|
||||||
|
* try ... catch
|
||||||
|
|
||||||
|
## Special cases
|
||||||
|
|
||||||
|
* exitWith...
|
||||||
|
* waitUntil...
|
||||||
|
* !buildInFunc()()...
|
||||||
|
|||||||
@@ -1,2 +1,39 @@
|
|||||||
//diag_log format ["easyHC: found headless client with ID %1.", easyHCpresent];
|
/*
|
||||||
diag_log () (format(xy)("asdf", "hjkl"));
|
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 {
|
||||||
|
exit()(); // does not work for SQF, need to implement exitWith...
|
||||||
|
}
|
||||||
|
|
||||||
|
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...catch
|
||||||
|
execVM(_unit)(_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ func parseParameter(out bool) (string, int) {
|
|||||||
func parseExpression(out bool) string {
|
func parseExpression(out bool) string {
|
||||||
output := parseArith()
|
output := parseArith()
|
||||||
|
|
||||||
for accept("<") || accept(">") || accept("&") || accept("|") || accept("=") {
|
for accept("<") || accept(">") || accept("&") || accept("|") || accept("=") || accept("!") {
|
||||||
if accept("<") {
|
if accept("<") {
|
||||||
output += "<"
|
output += "<"
|
||||||
next()
|
next()
|
||||||
@@ -341,9 +341,13 @@ func parseExpression(out bool) string {
|
|||||||
next()
|
next()
|
||||||
expect("|")
|
expect("|")
|
||||||
output += "||"
|
output += "||"
|
||||||
} else {
|
} else if accept("=") {
|
||||||
output += "="
|
output += "="
|
||||||
next()
|
next()
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
expect("=")
|
||||||
|
output += "!="
|
||||||
}
|
}
|
||||||
|
|
||||||
if accept("=") {
|
if accept("=") {
|
||||||
|
|||||||
@@ -94,6 +94,13 @@ func TestParserBuildinFunctionCall(t *testing.T) {
|
|||||||
equal(t, got, want)
|
equal(t, got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParserOperator(t *testing.T) {
|
||||||
|
got := getCompiled(t, "test/parser_operator.asl")
|
||||||
|
want := "if (x==y&&x!=y&&x<=y&&x>=y&&x<y&&x>y) then {\n};\n"
|
||||||
|
|
||||||
|
equal(t, got, want)
|
||||||
|
}
|
||||||
|
|
||||||
func getCompiled(t *testing.T, file string) string {
|
func getCompiled(t *testing.T, file string) string {
|
||||||
code, err := ioutil.ReadFile(file)
|
code, err := ioutil.ReadFile(file)
|
||||||
|
|
||||||
|
|||||||
3
test/parser_operator.asl
Normal file
3
test/parser_operator.asl
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
if x == y && x != y && x <= y && x >= y && x < y && x > y {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user