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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ var keywords = []string{
|
||||
"false",
|
||||
"case",
|
||||
"default",
|
||||
"return",
|
||||
"sqf"}
|
||||
"return"}
|
||||
|
||||
var whitespace = []byte{' ', '\n', '\t'}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user