diff --git a/ToDo.md b/ToDo.md index 66a6be7..0b6b56d 100644 --- a/ToDo.md +++ b/ToDo.md @@ -9,4 +9,4 @@ * recursive compiling * concurrent compiling * inline buildin function call -> foo(a)(bar(x)(y)); -* negative values e.g. -1, operator ! +* ~~negative values e.g. -1, operator !~~ diff --git a/in/complex.asl b/in/complex.asl index b3140cc..6d38b29 100644 --- a/in/complex.asl +++ b/in/complex.asl @@ -1,13 +1 @@ -diag_log()("easyHC: started"); -publicVariable()("easyHCpresent"); - -if isNil()("easyHCpresent") { - easyHCpresent = 1; // HC client ID -} - -if isServer()() && hasInterface()() { - easyHCpresent = owner()(player); - //diag_log()(format()("easyHC: found headless client with ID %1.", easyHCpresent)); -} - -// ... +foo(player)("head"); diff --git a/src/asl/parser.go b/src/asl/parser.go index a334e96..25a5555 100644 --- a/src/asl/parser.go +++ b/src/asl/parser.go @@ -379,10 +379,20 @@ func parseExpression(out bool) string { func parseIdentifier() string { output := "" - if seek("(") { + if seek("(") && !accept("!") && !accept("-") { name := get().token next() output = "("+parseFunctionCall(false, name)+")" + } else if accept("!") || accept("-") { + output = get().token + next() + + if !accept("(") { + output += get().token + next() + } else { + output += parseTerm() + } } else { output = get().token next() diff --git a/src/asl/parser_test.go b/src/asl/parser_test.go index e97f241..95e9894 100644 --- a/src/asl/parser_test.go +++ b/src/asl/parser_test.go @@ -68,7 +68,7 @@ func TestParserAssignResult(t *testing.T) { func TestParserExpression(t *testing.T) { got := getCompiled(t, "test/parser_expression.asl") - want := "x = (1+(2+3))/(6*(someVariable+99-100))-(20)+anotherVariable+([] call foo);\n" + want := "x = -(1+(2+3))/(6*(someVariable+99-100))-(20)+!anotherVariable+([] call foo);\n" equal(t, got, want) } diff --git a/test/parser_expression.asl b/test/parser_expression.asl index fc5b371..d56f5c2 100644 --- a/test/parser_expression.asl +++ b/test/parser_expression.asl @@ -1 +1 @@ -var x = (1+(2+3))/(6*(someVariable+99-100))-(20)+anotherVariable+foo(); +var x = -(1+(2+3))/(6*(someVariable+99-100))-(20)+!anotherVariable+foo();