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 package main
import ( import (
"github.com/surdeus/gomtool/src/mtool"
"github.com/surdeus/goblin/src/tool/awk" "github.com/surdeus/goblin/src/tool/awk"
"github.com/surdeus/goblin/src/tool/basename" "github.com/surdeus/goblin/src/tool/basename"
"github.com/surdeus/goblin/src/tool/cat" "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/wc"
"github.com/surdeus/goblin/src/tool/whoami" "github.com/surdeus/goblin/src/tool/whoami"
"github.com/surdeus/goblin/src/tool/yes" "github.com/surdeus/goblin/src/tool/yes"
"github.com/surdeus/goblin/src/tool/run" "github.com/surdeus/goblin/src/tool/anko"
"github.com/surdeus/gomtool/src/mtool"
) )
func main() { func main() {
@ -75,9 +76,9 @@ func main() {
"link files", "link files",
"", "",
}, },
"run": mtool.Tool{ "anko": mtool.Tool{
run.Run, anko.Run,
"run anko script", "run embedded anko",
"", "",
}, },
} }

View file

@ -1,9 +1,9 @@
# Anko # 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) [![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) [![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. Anko is a scriptable interpreter written in Go.
@ -21,8 +21,8 @@ import (
"fmt" "fmt"
"log" "log"
"github.com/surdeus/goblin/src/tool/run/env" "github.com/surdeus/goblin/src/tool/anko/env"
"github.com/surdeus/goblin/src/tool/run/vm" "github.com/surdeus/goblin/src/tool/anko/vm"
) )
func main() { func main() {
@ -48,15 +48,15 @@ println("Hello World :)")
More examples are located in the GoDoc: 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 ## Usage Example - Command Line
### Building ### Building
``` ```
go get github.com/surdeus/goblin/src/tool/run go get github.com/surdeus/goblin/src/tool/anko
go install github.com/surdeus/goblin/src/tool/run go install github.com/surdeus/goblin/src/tool/anko
``` ```
### Running an Anko script file named script.ank ### Running an Anko script file named script.ank
@ -129,7 +129,7 @@ Yasuhiro Matsumoto (a.k.a mattn)
### Code Contributors ### Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. 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 ### Financial Contributors

View file

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

View file

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

View file

@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"reflect" "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 // WalkFunc is used in Walk to walk the AST

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,7 @@ import (
"strings" "strings"
"time" "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 // ImportToX adds all the toX to the env given

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ import (
"math/big" "math/big"
"reflect" "reflect"
"github.com/surdeus/goblin/src/tool/run/env" "github.com/surdeus/goblin/src/tool/anko/env"
) )
func init() { func init() {
@ -16,7 +16,7 @@ func init() {
"Jacobi": reflect.ValueOf(big.Jacobi), "Jacobi": reflect.ValueOf(big.Jacobi),
"MaxBase": reflect.ValueOf(big.MaxBase), "MaxBase": reflect.ValueOf(big.MaxBase),
"MaxExp": reflect.ValueOf(big.MaxExp), "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), // "MaxPrec": reflect.ValueOf(big.MaxPrec),
"MinExp": reflect.ValueOf(big.MinExp), "MinExp": reflect.ValueOf(big.MinExp),
"NewFloat": reflect.ValueOf(big.NewFloat), "NewFloat": reflect.ValueOf(big.NewFloat),

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ import (
"reflect" "reflect"
"sort" "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 // SortFuncsStruct provides functions to be used with Sort

View file

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

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