Fixed buildin function call problem, but found a new on in tokenizer

(e.g. "format" -> for, mat).
This commit is contained in:
Marvin Blum
2015-10-24 14:37:12 +02:00
parent 75729ebb8e
commit 5996df0f71
6 changed files with 8 additions and 22 deletions

View File

@@ -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

View File

@@ -1 +1,2 @@
foo(player)("head");
//diag_log format ["easyHC: found headless client with ID %1.", easyHCpresent];
diag_log () (format(xy)("asdf", "hjkl"));

View File

@@ -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

View File

@@ -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)
}

View File

@@ -41,8 +41,7 @@ var keywords = []string{
"false",
"case",
"default",
"return",
"sqf"}
"return"}
var whitespace = []byte{' ', '\n', '\t'}

View File

@@ -1 +1 @@
var _x = setHit(player)("head");
var _x = setHit(getVar(player, foo)(bar))("head", "tail");