mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Fixed ! operator and negative value prefix (e.g. -100).
This commit is contained in:
2
ToDo.md
2
ToDo.md
@@ -9,4 +9,4 @@
|
|||||||
* recursive compiling
|
* recursive compiling
|
||||||
* concurrent compiling
|
* concurrent compiling
|
||||||
* 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 !~~
|
||||||
|
|||||||
@@ -1,13 +1 @@
|
|||||||
diag_log()("easyHC: started");
|
foo(player)("head");
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|||||||
@@ -379,10 +379,20 @@ func parseExpression(out bool) string {
|
|||||||
func parseIdentifier() string {
|
func parseIdentifier() string {
|
||||||
output := ""
|
output := ""
|
||||||
|
|
||||||
if seek("(") {
|
if seek("(") && !accept("!") && !accept("-") {
|
||||||
name := get().token
|
name := get().token
|
||||||
next()
|
next()
|
||||||
output = "("+parseFunctionCall(false, name)+")"
|
output = "("+parseFunctionCall(false, name)+")"
|
||||||
|
} else if accept("!") || accept("-") {
|
||||||
|
output = get().token
|
||||||
|
next()
|
||||||
|
|
||||||
|
if !accept("(") {
|
||||||
|
output += get().token
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
output += parseTerm()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
output = get().token
|
output = get().token
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func TestParserAssignResult(t *testing.T) {
|
|||||||
|
|
||||||
func TestParserExpression(t *testing.T) {
|
func TestParserExpression(t *testing.T) {
|
||||||
got := getCompiled(t, "test/parser_expression.asl")
|
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)
|
equal(t, got, want)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user