mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Fixed negation bug.
This commit is contained in:
@@ -36,7 +36,7 @@ func parseBlock() {
|
||||
} else if accept("return") {
|
||||
parseReturn()
|
||||
} else if accept("try") {
|
||||
parseTryCatch()
|
||||
parseTryCatch()
|
||||
} else if accept("case") || accept("default") {
|
||||
return
|
||||
} else {
|
||||
@@ -235,17 +235,17 @@ func parseReturn() {
|
||||
}
|
||||
|
||||
func parseTryCatch() {
|
||||
expect("try")
|
||||
expect("{")
|
||||
appendOut("try {", true)
|
||||
parseBlock()
|
||||
expect("}")
|
||||
expect("catch")
|
||||
expect("{")
|
||||
appendOut("} catch {", true)
|
||||
parseBlock()
|
||||
expect("}")
|
||||
appendOut("};", true)
|
||||
expect("try")
|
||||
expect("{")
|
||||
appendOut("try {", true)
|
||||
parseBlock()
|
||||
expect("}")
|
||||
expect("catch")
|
||||
expect("{")
|
||||
appendOut("} catch {", true)
|
||||
parseBlock()
|
||||
expect("}")
|
||||
appendOut("};", true)
|
||||
}
|
||||
|
||||
// Everything that does not start with a keyword.
|
||||
@@ -361,9 +361,9 @@ func parseExpression(out bool) string {
|
||||
output += "="
|
||||
next()
|
||||
} else {
|
||||
next()
|
||||
expect("=")
|
||||
output += "!="
|
||||
next()
|
||||
expect("=")
|
||||
output += "!="
|
||||
}
|
||||
|
||||
if accept("=") {
|
||||
@@ -391,13 +391,7 @@ func parseIdentifier() string {
|
||||
} else if accept("!") || accept("-") {
|
||||
output = get().token
|
||||
next()
|
||||
|
||||
if !accept("(") {
|
||||
output += get().token
|
||||
next()
|
||||
} else {
|
||||
output += parseTerm()
|
||||
}
|
||||
output += parseTerm()
|
||||
} else {
|
||||
output = get().token
|
||||
next()
|
||||
|
||||
@@ -108,6 +108,13 @@ func TestParserTryCatch(t *testing.T) {
|
||||
equal(t, got, want)
|
||||
}
|
||||
|
||||
func TestParserNegationFunctionCall(t *testing.T) {
|
||||
got := getCompiled(t, "test/parser_negation.asl")
|
||||
want := "x = !([] call foo);\n"
|
||||
|
||||
equal(t, got, want)
|
||||
}
|
||||
|
||||
func getCompiled(t *testing.T, file string) string {
|
||||
code, err := ioutil.ReadFile(file)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user