This commit is contained in:
W̷̛͒i̶̓͗l̷͗̌ľ̶͘ committed 2022-05-27 17:28:08 +01:00
1 parent 97476abfed
commit 48f3247100
6 files changed
+190 -35

No files matched your search

+89
View File
@@ -0,0 +1,89 @@
# .github/workflows/release.yaml
on: release
name: Build Release
jobs:
release-linux-386:
name: release linux/386
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: "386"
GOOS: linux
EXTRA_FILES: "LICENSE"
release-linux-amd64:
name: release linux/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: amd64
GOOS: linux
EXTRA_FILES: "LICENSE"
release-linux-arm:
name: release linux/386
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: "arm"
GOOS: linux
EXTRA_FILES: "LICENSE"
release-linux-arm64:
name: release linux/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: arm64
GOOS: linux
EXTRA_FILES: "LICENSE"
release-darwin-amd64:
name: release darwin/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: amd64
GOOS: darwin
EXTRA_FILES: "LICENSE"
release-windows-386:
name: release windows/386
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: "386"
GOOS: windows
EXTRA_FILES: "LICENSE"
release-windows-amd64:
name: release windows/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: compile and release
uses: ngs/go-release.action@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: amd64
GOOS: windows
EXTRA_FILES: "LICENSE"
View File
File renamed without changes.
+1 -1
View File
@@ -1 +1 @@
184+103 1+1
+1 -1
View File
@@ -1,3 +1,3 @@
module main module main
go 1.16 go 1.18
+98 -30
View File
@@ -13,11 +13,15 @@ func init() {
runop = runprocess runop = runprocess
} }
func run(lines []interface{}) { func run(lines []any) {
fmt.Println(runprocess(lines[0])) for i := 0; i < len(lines); i++ {
if lines[i] != nil {
fmt.Println(runprocess(lines[i]))
}
}
} }
func runprocess(codeseg interface{}) interface{} { func runprocess(codeseg any) any {
switch codeseg.(type) { switch codeseg.(type) {
case opperator: case opperator:
return runOperator(codeseg.(opperator)) return runOperator(codeseg.(opperator))
@@ -26,12 +30,30 @@ func runprocess(codeseg interface{}) interface{} {
if myvar.EXISTS != nil { if myvar.EXISTS != nil {
return myvar.VAL return myvar.VAL
} }
log.Fatal("undecared variable on line " + fmt.Sprint(codeseg.(variable).line)) log.Fatal("undecared variable on line " + fmt.Sprint(codeseg.(variable).line))
case setVariable:
} }
return codeseg return codeseg
} }
func dynamicAdd(x interface{}, y interface{}) interface{} { func setVariableVal(x setVariable) {
variable := vars[x.variable]
if variable.EXISTS != nil || variable.TYPE == "var" {
vars[x.variable] = variableValue{
TYPE: x.variable,
EXISTS: true,
VAL: x.value,
FUNC: false,
}
} else if variable.EXISTS != nil {
log.Fatal("undecared variable on line " + fmt.Sprint(x.line))
} else {
log.Fatal("cannot edit " + variable.TYPE + " variable on line " + fmt.Sprint(x.line))
}
}
func dynamicAdd(x any, y any) any {
stringconvert := false stringconvert := false
switch x.(type) { switch x.(type) {
case string: case string:
@@ -44,18 +66,12 @@ func dynamicAdd(x interface{}, y interface{}) interface{} {
if stringconvert { if stringconvert {
return fmt.Sprint(x) + fmt.Sprint(y) return fmt.Sprint(x) + fmt.Sprint(y)
} }
xnum, err := strconv.ParseFloat(fmt.Sprint(x), 64) xnum := number(x)
if err != nil { ynum := number(y)
log.Fatal(err)
}
ynum, err := strconv.ParseFloat(fmt.Sprint(y), 64)
if err != nil {
log.Fatal(err)
}
return xnum + ynum return xnum + ynum
} }
func xiny(x interface{}, y []interface{}) bool { func xiny(x any, y []any) bool {
for i := 0; i < len(y); i++ { for i := 0; i < len(y); i++ {
if x == y[i] { if x == y[i] {
return true return true
@@ -64,45 +80,97 @@ func xiny(x interface{}, y []interface{}) bool {
return false return false
} }
func runOperator(opperation opperator) interface{} { func number(x any) float64 {
x := runop(opperation.x) num, err := strconv.ParseFloat(fmt.Sprint(x), 64)
y := runop(opperation.y) if err != nil {
var output interface{} log.Fatal(err)
}
return num
}
func runOperator(opperation opperator) any {
var output any
switch opperation.t { switch opperation.t {
case 0: case 0:
output = (x != false && x != nil) && (y != false && y != nil) x := runop(opperation.x)
y := runop(opperation.y)
if (x != false && x != nil) && (y != false && y != nil) {
output = y
} else {
output = false
}
case 1: case 1:
output = x.(bool) || y.(bool) x := runop(opperation.x)
if x != false && x != nil {
output = x
} else {
y := runop(opperation.y)
if y != false && y != nil {
output = y
} else {
output = false
}
}
case 2: case 2:
x := runop(opperation.x)
y := runop(opperation.y)
output = xiny(x, y.([]interface{})) output = xiny(x, y.([]interface{}))
case 3: case 3:
x := runop(opperation.x)
y := runop(opperation.y)
output = !xiny(x, y.([]interface{})) output = !xiny(x, y.([]interface{}))
case 4: case 4:
output = (x.(float64) <= y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = (number(x) <= number(y))
case 5: case 5:
output = (x.(float64) >= y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = (number(x) >= number(y))
case 6: case 6:
output = (x.(float64) < y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = (number(x) < number(y))
case 7: case 7:
output = (x.(float64) > y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = (number(x) > number(y))
case 8: case 8:
x := runop(opperation.x)
y := runop(opperation.y)
output = (x != y) output = (x != y)
case 9: case 9:
x := runop(opperation.x)
y := runop(opperation.y)
output = (x == y) output = (x == y)
case 10: case 10:
output = (x.(float64) - y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = (number(x) - number(y))
case 11: case 11:
x := runop(opperation.x)
y := runop(opperation.y)
output = dynamicAdd(x, y) output = dynamicAdd(x, y)
case 12: case 12:
output = math.Pow(x.(float64), 1/y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = math.Pow(number(x), 1/number(y))
case 13: case 13:
output = math.Pow(x.(float64), y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = math.Pow(number(x), number(y))
case 14: case 14:
output = x.(float64) * y.(float64) x := runop(opperation.x)
y := runop(opperation.y)
output = number(x) * number(y)
case 15: case 15:
output = math.Floor(x.(float64) / y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = math.Floor(number(x) / number(y))
case 16: case 16:
output = math.Floor(x.(float64) / y.(float64)) x := runop(opperation.x)
y := runop(opperation.y)
output = math.Floor(number(x) / number(y))
} }
return output return output
} }
+1 -3
View File
@@ -7,7 +7,7 @@ import (
"strings" "strings"
) )
var stringCompile = makeRegex("( *)((\"((\\\\([a-z\\\"']))|[^\\\"])*\"))|(('((\\\\([a-z\\'\"]))|[^\\'])*'))( *)") var stringCompile = makeRegex("(( *)\"((\\\\([a-z\\\"']))|[^\\\"])*\"( *)))|((( *)'((\\\\([a-z\\'\"]))|[^\\'])*'( *))")
var numberCompile = makeRegex("( *)(\\-)?(([0-9]+(\\.[0-9]+)?)(e((\\-|\\+)?([0-9]+(\\.[0-9]+)?)))?)( *)") var numberCompile = makeRegex("( *)(\\-)?(([0-9]+(\\.[0-9]+)?)(e((\\-|\\+)?([0-9]+(\\.[0-9]+)?)))?)( *)")
var whileCompile = makeRegex("( *)(while .+ \\[.*)( *)") var whileCompile = makeRegex("( *)(while .+ \\[.*)( *)")
var ifCompile = makeRegex("( *)(if .+ \\[.*)( *)") var ifCompile = makeRegex("( *)(if .+ \\[.*)( *)")
@@ -83,7 +83,6 @@ var opperators = [][]string{
" to the power of ", " to the power of ",
"^", "^",
"**", "**",
"*",
}, { }, {
"*", "*",
" x ", " x ",
@@ -191,7 +190,6 @@ var translateprocess = func(codeseg code) (interface{}, bool) {
} }
} }
} }
if stringCompile.MatchString(codeseg.code) { if stringCompile.MatchString(codeseg.code) {
return (stringencode(codeseg.code)), true return (stringencode(codeseg.code)), true
} else if bracketsCompile.MatchString(codeseg.code) { } else if bracketsCompile.MatchString(codeseg.code) {