Renamed run -> anko.

This commit is contained in:
Andrey Parhomenko 2023-06-09 18:01:53 +03:00
parent c52438956c
commit 23c55cb466
142 changed files with 134 additions and 117 deletions

8
check.anko Normal file
View file

@ -0,0 +1,8 @@
e = 5
v = 53
println(e + v)
if v < 55 {
println("it fucking works")
}

View file

@ -1,6 +1,8 @@
package main
import (
"github.com/surdeus/gomtool/src/mtool"
"github.com/surdeus/goblin/src/tool/awk"
"github.com/surdeus/goblin/src/tool/basename"
"github.com/surdeus/goblin/src/tool/cat"
@ -29,8 +31,7 @@ import (
"github.com/surdeus/goblin/src/tool/wc"
"github.com/surdeus/goblin/src/tool/whoami"
"github.com/surdeus/goblin/src/tool/yes"
"github.com/surdeus/goblin/src/tool/run"
"github.com/surdeus/gomtool/src/mtool"
"github.com/surdeus/goblin/src/tool/anko"
)
func main() {
@ -75,9 +76,9 @@ func main() {
"link files",
"",
},
"run": mtool.Tool{
run.Run,
"run anko script",
"anko": mtool.Tool{
anko.Run,
"run embedded anko",
"",
},
}

View file

@ -1,9 +1,9 @@
# Anko
[![GoDoc Reference](https://godoc.org/github.com/surdeus/goblin/src/tool/run/vm?status.svg)](http://godoc.org/github.com/surdeus/goblin/src/tool/run/vm)
[![GoDoc Reference](https://godoc.org/github.com/surdeus/goblin/src/tool/anko/vm?status.svg)](http://godoc.org/github.com/surdeus/goblin/src/tool/anko/vm)
[![Build Status](https://travis-ci.org/mattn/anko.svg?branch=master)](https://travis-ci.org/mattn/anko)
[![Financial Contributors on Open Collective](https://opencollective.com/mattn-anko/all/badge.svg?label=financial+contributors)](https://opencollective.com/mattn-anko) [![Coverage](https://codecov.io/gh/mattn/anko/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/anko)
[![Go Report Card](https://goreportcard.com/badge/github.com/surdeus/goblin/src/tool/run)](https://goreportcard.com/report/github.com/surdeus/goblin/src/tool/run)
[![Go Report Card](https://goreportcard.com/badge/github.com/surdeus/goblin/src/tool/anko)](https://goreportcard.com/report/github.com/surdeus/goblin/src/tool/anko)
Anko is a scriptable interpreter written in Go.
@ -21,8 +21,8 @@ import (
"fmt"
"log"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/run/vm"
"github.com/surdeus/goblin/src/tool/anko/env"
"github.com/surdeus/goblin/src/tool/anko/vm"
)
func main() {
@ -48,15 +48,15 @@ println("Hello World :)")
More examples are located in the GoDoc:
https://godoc.org/github.com/surdeus/goblin/src/tool/run/vm
https://godoc.org/github.com/surdeus/goblin/src/tool/anko/vm
## Usage Example - Command Line
### Building
```
go get github.com/surdeus/goblin/src/tool/run
go install github.com/surdeus/goblin/src/tool/run
go get github.com/surdeus/goblin/src/tool/anko
go install github.com/surdeus/goblin/src/tool/anko
```
### Running an Anko script file named script.ank
@ -129,7 +129,7 @@ Yasuhiro Matsumoto (a.k.a mattn)
### Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="https://github.com/surdeus/goblin/src/tool/run/graphs/contributors"><img src="https://opencollective.com/mattn-anko/contributors.svg?width=890&button=false" /></a>
<a href="https://github.com/surdeus/goblin/src/tool/anko/graphs/contributors"><img src="https://opencollective.com/mattn-anko/contributors.svg?width=890&button=false" /></a>
### Financial Contributors

View file

@ -1,6 +1,6 @@
// +build !appengine
package run
package anko
import (
"bufio"
@ -11,11 +11,11 @@ import (
"os"
"strings"
"github.com/surdeus/goblin/src/tool/run/core"
"github.com/surdeus/goblin/src/tool/run/env"
_ "github.com/surdeus/goblin/src/tool/run/packages"
"github.com/surdeus/goblin/src/tool/run/parser"
"github.com/surdeus/goblin/src/tool/run/vm"
"github.com/surdeus/goblin/src/tool/anko/core"
"github.com/surdeus/goblin/src/tool/anko/env"
_ "github.com/surdeus/goblin/src/tool/anko/packages"
"github.com/surdeus/goblin/src/tool/anko/parser"
"github.com/surdeus/goblin/src/tool/anko/vm"
"github.com/surdeus/gomtool/src/mtool"
"os/exec"
)
@ -43,11 +43,9 @@ func Run(flagSet *mtool.Flags) {
parseFlags()
setupEnv()
if flagExecute != "" || flag.NArg() > 0 {
exitCode = runNonInteractive()
} else {
exitCode = runInteractive()
}
exitCode = runNonInteractive()
//if flagExecute != "" || flag.NArg() > 0 {
//}
os.Exit(exitCode)
}
@ -161,7 +159,15 @@ func runNonInteractive() int {
if flagExecute != "" {
source = flagExecute
} else {
sourceBytes, err := ioutil.ReadFile(file)
var (
sourceBytes []byte
err error
)
if file == "#stdin" {
sourceBytes, err = io.ReadAll(os.Stdin)
} else {
sourceBytes, err = ioutil.ReadFile(file)
}
if err != nil {
fmt.Println("ReadFile error:", err)
return 2

View file

@ -1,6 +1,6 @@
// +build !appengine
package run
package anko
import (
"bufio"

View file

@ -6,7 +6,7 @@ import (
"fmt"
"reflect"
"github.com/surdeus/goblin/src/tool/run/ast"
"github.com/surdeus/goblin/src/tool/anko/ast"
)
// WalkFunc is used in Walk to walk the AST

View file

@ -5,8 +5,8 @@ import (
"fmt"
"testing"
"github.com/surdeus/goblin/src/tool/run/ast"
"github.com/surdeus/goblin/src/tool/run/parser"
"github.com/surdeus/goblin/src/tool/anko/ast"
"github.com/surdeus/goblin/src/tool/anko/parser"
)
const (

View file

@ -6,9 +6,9 @@ import (
"io/ioutil"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/run/parser"
"github.com/surdeus/goblin/src/tool/run/vm"
"github.com/surdeus/goblin/src/tool/anko/env"
"github.com/surdeus/goblin/src/tool/anko/parser"
"github.com/surdeus/goblin/src/tool/anko/vm"
)
// Import defines core language builtins - keys, range, println, etc.

View file

@ -7,8 +7,8 @@ import (
"strings"
"testing"
"github.com/surdeus/goblin/src/tool/run/packages"
"github.com/surdeus/goblin/src/tool/run/vm"
"github.com/surdeus/goblin/src/tool/anko/packages"
"github.com/surdeus/goblin/src/tool/anko/vm"
)
var testCoreEnvSetupFunc = func(t *testing.T, env corelib.Env) { Import(env.(*vm.Env)) }

View file

@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/surdeus/goblin/src/tool/run/internal/testlib"
"github.com/surdeus/goblin/src/tool/anko/internal/testlib"
)
func TestToX(t *testing.T) {

View file

@ -7,7 +7,7 @@ import (
"strings"
"time"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
// ImportToX adds all the toX to the env given

View file

@ -8,10 +8,10 @@ import (
"strings"
"syscall/js"
"github.com/surdeus/goblin/src/tool/run/core"
"github.com/surdeus/goblin/src/tool/run/packages"
"github.com/surdeus/goblin/src/tool/run/parser"
"github.com/surdeus/goblin/src/tool/run/vm"
"github.com/surdeus/goblin/src/tool/anko/core"
"github.com/surdeus/goblin/src/tool/anko/packages"
"github.com/surdeus/goblin/src/tool/anko/parser"
"github.com/surdeus/goblin/src/tool/anko/vm"
)
var (

View file

@ -4,7 +4,7 @@ import (
"bytes"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -6,7 +6,7 @@ import (
"bytes"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func bytesGo17() {

View file

@ -4,7 +4,7 @@ import (
"encoding/json"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"errors"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"flag"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"fmt"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"io"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"io/ioutil"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"log"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"math/big"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {
@ -16,7 +16,7 @@ func init() {
"Jacobi": reflect.ValueOf(big.Jacobi),
"MaxBase": reflect.ValueOf(big.MaxBase),
"MaxExp": reflect.ValueOf(big.MaxExp),
// TODO: https://github.com/surdeus/goblin/src/tool/run/issues/49
// TODO: https://github.com/surdeus/goblin/src/tool/anko/issues/49
// "MaxPrec": reflect.ValueOf(big.MaxPrec),
"MinExp": reflect.ValueOf(big.MinExp),
"NewFloat": reflect.ValueOf(big.NewFloat),

View file

@ -4,7 +4,7 @@ import (
"math"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"math/rand"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -6,7 +6,7 @@ import (
"net"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"net/http/cookiejar"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -6,7 +6,7 @@ import (
"net/http"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -6,7 +6,7 @@ import (
"net/url"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"os/exec"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"os"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"os/signal"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -6,7 +6,7 @@ import (
"os"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func osNotAppEngine() {

View file

@ -4,7 +4,7 @@ import (
"path/filepath"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"path"
"reflect"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"reflect"
"regexp"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"reflect"
"runtime"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func init() {

View file

@ -4,7 +4,7 @@ import (
"reflect"
"sort"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
// SortFuncsStruct provides functions to be used with Sort

View file

@ -6,7 +6,7 @@ import (
"reflect"
"sort"
"github.com/surdeus/goblin/src/tool/run/env"
"github.com/surdeus/goblin/src/tool/anko/env"
)
func sortGo18() {

Some files were not shown because too many files have changed in this diff Show more