mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Fixed buildin function call problem, but found a new on in tokenizer
(e.g. "format" -> for, mat).
This commit is contained in:
3
ToDo.md
3
ToDo.md
@@ -8,5 +8,6 @@
|
|||||||
* ~~usage~~
|
* ~~usage~~
|
||||||
* 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 !~~
|
||||||
|
* tokenizer splits commands like "format" -> for, mat
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
foo(player)("head");
|
//diag_log format ["easyHC: found headless client with ID %1.", easyHCpresent];
|
||||||
|
diag_log () (format(xy)("asdf", "hjkl"));
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ func parseBlock() {
|
|||||||
parseFunction()
|
parseFunction()
|
||||||
} else if accept("return") {
|
} else if accept("return") {
|
||||||
parseReturn()
|
parseReturn()
|
||||||
} else if accept("sqf") {
|
|
||||||
parseSqf()
|
|
||||||
} else if accept("case") || accept("default") {
|
} else if accept("case") || accept("default") {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -234,19 +232,6 @@ func parseReturn() {
|
|||||||
appendOut(";", true)
|
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.
|
// Everything that does not start with a keyword.
|
||||||
func parseStatement() {
|
func parseStatement() {
|
||||||
// empty block
|
// empty block
|
||||||
@@ -301,7 +286,7 @@ func parseFunctionCall(out bool, name string) string {
|
|||||||
rightParams = "["+rightParams+"]"
|
rightParams = "["+rightParams+"]"
|
||||||
}
|
}
|
||||||
|
|
||||||
if leftParamCount > 1 {
|
if leftParamCount > 0 {
|
||||||
output = leftParams+" "+name+" "+rightParams
|
output = leftParams+" "+name+" "+rightParams
|
||||||
} else {
|
} else {
|
||||||
output = name+" "+rightParams
|
output = name+" "+rightParams
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func TestParserFunctionCall(t *testing.T) {
|
|||||||
|
|
||||||
func TestParserBuildinFunctionCall(t *testing.T) {
|
func TestParserBuildinFunctionCall(t *testing.T) {
|
||||||
got := getCompiled(t, "test/parser_buildin_func.asl")
|
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)
|
equal(t, got, want)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ var keywords = []string{
|
|||||||
"false",
|
"false",
|
||||||
"case",
|
"case",
|
||||||
"default",
|
"default",
|
||||||
"return",
|
"return"}
|
||||||
"sqf"}
|
|
||||||
|
|
||||||
var whitespace = []byte{' ', '\n', '\t'}
|
var whitespace = []byte{' ', '\n', '\t'}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
var _x = setHit(player)("head");
|
var _x = setHit(getVar(player, foo)(bar))("head", "tail");
|
||||||
|
|||||||
Reference in New Issue
Block a user