mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
go fmt.
This commit is contained in:
@@ -188,12 +188,12 @@ func parseForeach() {
|
||||
appendOut("{", true)
|
||||
parseBlock()
|
||||
expect("}")
|
||||
appendOut("} forEach (" + expr + ");", true)
|
||||
appendOut("} forEach ("+expr+");", true)
|
||||
}
|
||||
|
||||
func parseFunction() {
|
||||
expect("func")
|
||||
appendOut(get().token + " = {", true)
|
||||
appendOut(get().token+" = {", true)
|
||||
next()
|
||||
expect("(")
|
||||
parseFunctionParameter()
|
||||
@@ -215,7 +215,7 @@ func parseFunctionParameter() {
|
||||
for !accept(")") {
|
||||
name := get().token
|
||||
next()
|
||||
appendOut(name + " = _this select " + strconv.FormatInt(i, 10) + ";", true)
|
||||
appendOut(name+" = _this select "+strconv.FormatInt(i, 10)+";", true)
|
||||
i++
|
||||
|
||||
if !accept(")") {
|
||||
@@ -279,20 +279,20 @@ func parseFunctionCall(out bool, name string) string {
|
||||
expect(")")
|
||||
|
||||
if leftParamCount > 1 {
|
||||
leftParams = "["+leftParams+"]"
|
||||
leftParams = "[" + leftParams + "]"
|
||||
}
|
||||
|
||||
if rightParamCount > 1 {
|
||||
rightParams = "["+rightParams+"]"
|
||||
rightParams = "[" + rightParams + "]"
|
||||
}
|
||||
|
||||
if leftParamCount > 0 {
|
||||
output = leftParams+" "+name+" "+rightParams
|
||||
output = leftParams + " " + name + " " + rightParams
|
||||
} else {
|
||||
output = name+" "+rightParams
|
||||
output = name + " " + rightParams
|
||||
}
|
||||
} else {
|
||||
output = "["+leftParams+"] call "+name
|
||||
output = "[" + leftParams + "] call " + name
|
||||
}
|
||||
|
||||
if out {
|
||||
@@ -367,7 +367,7 @@ func parseIdentifier() string {
|
||||
if seek("(") && !accept("!") && !accept("-") {
|
||||
name := get().token
|
||||
next()
|
||||
output = "("+parseFunctionCall(false, name)+")"
|
||||
output = "(" + parseFunctionCall(false, name) + ")"
|
||||
} else if accept("!") || accept("-") {
|
||||
output = get().token
|
||||
next()
|
||||
@@ -389,7 +389,7 @@ func parseIdentifier() string {
|
||||
func parseTerm() string {
|
||||
if accept("(") {
|
||||
expect("(")
|
||||
output := "("+parseExpression(false)+")"
|
||||
output := "(" + parseExpression(false) + ")"
|
||||
expect(")")
|
||||
|
||||
return output
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package asl_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"io/ioutil"
|
||||
"asl"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParserDeclaration(t *testing.T) {
|
||||
@@ -98,7 +98,7 @@ func getCompiled(t *testing.T, file string) string {
|
||||
code, err := ioutil.ReadFile(file)
|
||||
|
||||
if err != nil {
|
||||
t.Error("Could not read test file: "+file)
|
||||
t.Error("Could not read test file: " + file)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package asl
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTokenizerVar(t *testing.T) {
|
||||
@@ -83,11 +83,11 @@ func compareLength(t *testing.T, got *[]Token, want *[]string) {
|
||||
gotlist, wantlist := "", ""
|
||||
|
||||
for i := range *got {
|
||||
gotlist += (*got)[i].token+" "
|
||||
gotlist += (*got)[i].token + " "
|
||||
}
|
||||
|
||||
for i := range *want {
|
||||
wantlist += (*want)[i]+" "
|
||||
wantlist += (*want)[i] + " "
|
||||
}
|
||||
|
||||
t.Log(gotlist)
|
||||
@@ -100,7 +100,7 @@ func compareLength(t *testing.T, got *[]Token, want *[]string) {
|
||||
func compareTokens(t *testing.T, got *[]Token, want *[]string) {
|
||||
for i := range *got {
|
||||
if (*got)[i].token != (*want)[i] {
|
||||
t.Error("Tokens do not match: "+(*got)[i].token+" != "+(*want)[i])
|
||||
t.Error("Tokens do not match: " + (*got)[i].token + " != " + (*want)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func getTokens(t *testing.T, file string) []Token {
|
||||
code, err := ioutil.ReadFile(file)
|
||||
|
||||
if err != nil {
|
||||
t.Error("Could not read test file: "+file)
|
||||
t.Error("Could not read test file: " + file)
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
|
||||
@@ -23,5 +23,5 @@ func main() {
|
||||
token := asl.Tokenize(code)
|
||||
out := asl.Parse(token, true)
|
||||
|
||||
fmt.Print("OUTPUT:\n-------\n"+out)
|
||||
fmt.Print("OUTPUT:\n-------\n" + out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user