mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
gofmt.
This commit is contained in:
Binary file not shown.
@@ -164,12 +164,12 @@ func parseForeach() {
|
|||||||
appendOut("{\n")
|
appendOut("{\n")
|
||||||
parseBlock()
|
parseBlock()
|
||||||
expect("}")
|
expect("}")
|
||||||
appendOut("} forEach ("+expr+");\n")
|
appendOut("} forEach (" + expr + ");\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFunction() {
|
func parseFunction() {
|
||||||
expect("func")
|
expect("func")
|
||||||
appendOut(get().token+" = {\n")
|
appendOut(get().token + " = {\n")
|
||||||
next()
|
next()
|
||||||
expect("(")
|
expect("(")
|
||||||
parseFunctionParameter()
|
parseFunctionParameter()
|
||||||
@@ -183,7 +183,7 @@ func parseFunction() {
|
|||||||
func parseFunctionParameter() {
|
func parseFunctionParameter() {
|
||||||
// empty parameter list
|
// empty parameter list
|
||||||
if accept("{") {
|
if accept("{") {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
i := int64(0)
|
i := int64(0)
|
||||||
@@ -191,7 +191,7 @@ func parseFunctionParameter() {
|
|||||||
for !accept(")") {
|
for !accept(")") {
|
||||||
name := get().token
|
name := get().token
|
||||||
next()
|
next()
|
||||||
appendOut(name+" = _this select "+strconv.FormatInt(i, 10)+";\n")
|
appendOut(name + " = _this select " + strconv.FormatInt(i, 10) + ";\n")
|
||||||
i++
|
i++
|
||||||
|
|
||||||
if !accept(")") {
|
if !accept(")") {
|
||||||
@@ -238,10 +238,10 @@ func parseStatement() {
|
|||||||
} else if name == "$" {
|
} else if name == "$" {
|
||||||
name = get().token
|
name = get().token
|
||||||
next()
|
next()
|
||||||
parseBuildinFunctionCall(name);
|
parseBuildinFunctionCall(name)
|
||||||
} else {
|
} else {
|
||||||
parseFunctionCall()
|
parseFunctionCall()
|
||||||
appendOut(name+";\n")
|
appendOut(name + ";\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !end() {
|
if !end() {
|
||||||
@@ -251,7 +251,7 @@ func parseStatement() {
|
|||||||
|
|
||||||
func parseAssignment() {
|
func parseAssignment() {
|
||||||
expect("=")
|
expect("=")
|
||||||
appendOut(" = "+get().token)
|
appendOut(" = " + get().token)
|
||||||
next()
|
next()
|
||||||
expect(";")
|
expect(";")
|
||||||
appendOut(";\n")
|
appendOut(";\n")
|
||||||
@@ -273,7 +273,7 @@ func parseBuildinFunctionCall(name string) {
|
|||||||
expect(")")
|
expect(")")
|
||||||
appendOut("] ")
|
appendOut("] ")
|
||||||
expect("(")
|
expect("(")
|
||||||
appendOut(name+" [")
|
appendOut(name + " [")
|
||||||
parseParameter()
|
parseParameter()
|
||||||
expect(")")
|
expect(")")
|
||||||
expect(";")
|
expect(";")
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func accept(token string) bool {
|
|||||||
|
|
||||||
func expect(token string) {
|
func expect(token string) {
|
||||||
if !tokenEqual(token, get()) {
|
if !tokenEqual(token, get()) {
|
||||||
panic("Parse error, expected '"+token+"' but was '"+get().token+"'")
|
panic("Parse error, expected '" + token + "' but was '" + get().token + "'")
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package asl
|
package asl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Token struct{
|
type Token struct {
|
||||||
token string
|
token string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,13 +116,13 @@ func skipMultiLineComment(code []byte, i int) int {
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
return i+1
|
return i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func byteArrayContains(haystack []byte, needle byte) bool {
|
func byteArrayContains(haystack []byte, needle byte) bool {
|
||||||
for i := range haystack {
|
for i := range haystack {
|
||||||
if haystack[i] == needle {
|
if haystack[i] == needle {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ func byteArrayContains(haystack []byte, needle byte) bool {
|
|||||||
func stringArrayContains(haystack []string, needle string) bool {
|
func stringArrayContains(haystack []string, needle string) bool {
|
||||||
for i := range haystack {
|
for i := range haystack {
|
||||||
if haystack[i] == needle {
|
if haystack[i] == needle {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"asl"
|
"asl"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main(){
|
func main() {
|
||||||
// read test file
|
// read test file
|
||||||
code, _ := ioutil.ReadFile("in/simple.asl")
|
code, _ := ioutil.ReadFile("in/simple.asl")
|
||||||
token := asl.Tokenize(code)
|
token := asl.Tokenize(code)
|
||||||
|
|||||||
Reference in New Issue
Block a user