diff --git a/ToDo.md b/ToDo.md index 0b6b56d..01f9c72 100644 --- a/ToDo.md +++ b/ToDo.md @@ -8,5 +8,6 @@ * ~~usage~~ * recursive 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 !~~ +* tokenizer splits commands like "format" -> for, mat diff --git a/in/complex.asl b/in/complex.asl index 6d38b29..2fe4670 100644 --- a/in/complex.asl +++ b/in/complex.asl @@ -1 +1,2 @@ -foo(player)("head"); +//diag_log format ["easyHC: found headless client with ID %1.", easyHCpresent]; +diag_log () (format(xy)("asdf", "hjkl")); diff --git a/src/asl/parser.go b/src/asl/parser.go index 25a5555..89af9ec 100644 --- a/src/asl/parser.go +++ b/src/asl/parser.go @@ -35,8 +35,6 @@ func parseBlock() { parseFunction() } else if accept("return") { parseReturn() - } else if accept("sqf") { - parseSqf() } else if accept("case") || accept("default") { return } else { @@ -234,19 +232,6 @@ func parseReturn() { appendOut(";", true) } -func parseSqf() { - expect("sqf") - expect(":") - - for !accept("sqf") { - appendOut(get().token, false) - next() - } - - appendOut("", true) - expect("sqf") -} - // Everything that does not start with a keyword. func parseStatement() { // empty block @@ -301,7 +286,7 @@ func parseFunctionCall(out bool, name string) string { rightParams = "["+rightParams+"]" } - if leftParamCount > 1 { + if leftParamCount > 0 { output = leftParams+" "+name+" "+rightParams } else { output = name+" "+rightParams diff --git a/src/asl/parser_test.go b/src/asl/parser_test.go index 95e9894..a725bd5 100644 --- a/src/asl/parser_test.go +++ b/src/asl/parser_test.go @@ -89,7 +89,7 @@ func TestParserFunctionCall(t *testing.T) { func TestParserBuildinFunctionCall(t *testing.T) { got := getCompiled(t, "test/parser_buildin_func.asl") - want := "_x = (setHit \"head\");\n" + want := "_x = (([player, foo] getVar bar) setHit [\"head\", \"tail\"]);\n" equal(t, got, want) } diff --git a/src/asl/tokenizer.go b/src/asl/tokenizer.go index a67d544..182a24b 100644 --- a/src/asl/tokenizer.go +++ b/src/asl/tokenizer.go @@ -41,8 +41,7 @@ var keywords = []string{ "false", "case", "default", - "return", - "sqf"} + "return"} var whitespace = []byte{' ', '\n', '\t'} diff --git a/test/parser_buildin_func.asl b/test/parser_buildin_func.asl index 3f34ff2..0b36daa 100644 --- a/test/parser_buildin_func.asl +++ b/test/parser_buildin_func.asl @@ -1 +1 @@ -var _x = setHit(player)("head"); +var _x = setHit(getVar(player, foo)(bar))("head", "tail");