Giter Site home page Giter Site logo

go-eval's Introduction

go-eval

Build Status GoDoc

This is the new home for the exp/eval package: the beginning of an interpreter for Go.

Installation

$ go get github.com/sbinet/go-eval/...

Usage

$ go-eval
:: welcome to go-eval...
(hit ^D to exit)
> hello := "world"
> println(hello)
world
>

Documentation

http://godoc.org/github.com/sbinet/go-eval

Limitations (aka TODO)

  • channels are not implemented
  • imports are not implemented
  • goroutines are not implemented
  • consts are not implemented
  • select is not implemented

Interpreter

The go-eval command is rather barebone. But there is igo which is built on top of the eval package and provides some additional refinements.

See:

$ go get github.com/sbinet/igo

go-eval's People

Contributors

atomsymbol-notifications avatar garyburd avatar ivorget avatar sbinet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-eval's Issues

const not implemented

Importing modules that define constants with "const" causes a panic:
panic: const not implemented

go version go1.0.3 on linux_amd64

go-eval version: commit 7de4c49

I am very excited to have a Go interpreter in which to try things out! (Contrary to some conversations on golang-nuts, I see the primary value of an interpreter as an interactive computing environment a la IPython.) I eagerly await future versions with more features.

import "math" caused panic

:) data $ go-eval
:: welcome to go-eval...
(hit ^D to exit)
> import "math"
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x90f2e]

goroutine 1 [running]:
runtime.panic(0x1e9240, 0x4ba179)
    /usr/local/Cellar/go/1.2/libexec/src/pkg/runtime/panic.c:266 +0xb6
github.com/sbinet/go-eval/pkg/eval.(*blockCompiler).compileStmts(0x2107536c0, 0x0)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/stmt.go:1245 +0x1e
github.com/sbinet/go-eval/pkg/eval.(*compiler).compileFunc(0x210753540, 0x2107542c0, 0x210754380, 0x0, 0x0)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/stmt.go:1304 +0x4cf
github.com/sbinet/go-eval/pkg/eval.(*stmtCompiler).compileDecl(0x210753640, 0x58d6f8, 0x210662ed0)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/stmt.go:428 +0x3d2
github.com/sbinet/go-eval/pkg/eval.(*stmtCompiler).compileDeclStmt(0x210753640, 0x2106fa410)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/stmt.go:351 +0x17f
github.com/sbinet/go-eval/pkg/eval.(*stmtCompiler).compile(0x210753640, 0x58da28, 0x2106fa410)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/stmt.go:263 +0x758
github.com/sbinet/go-eval/pkg/eval.(*blockCompiler).compileStmt(0x2107535a0, 0x58da28, 0x2106fa410)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/stmt.go:1241 +0x7e
github.com/sbinet/go-eval/pkg/eval.(*World).CompileStmtList(0x21061c240, 0x210601880, 0x21074f8c0, 0x5, 0x5, ...)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/world.go:183 +0x374
github.com/sbinet/go-eval/pkg/eval.(*World).CompileDeclList(0x21061c240, 0x210601880, 0x21074f870, 0x5, 0x5, ...)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/world.go:198 +0x189
github.com/sbinet/go-eval/pkg/eval.(*World).CompilePackage(0x21061c240, 0x210601880, 0x2106b57b8, 0x1, 0x1, ...)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/world.go:132 +0xa75
github.com/sbinet/go-eval/pkg/eval.(*World).CompilePackage(0x21061c240, 0x210601880, 0x210740200, 0x2a, 0x40, ...)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/world.go:104 +0xf81
github.com/sbinet/go-eval/pkg/eval.(*World).compileImport(0x21061c240, 0x210601880, 0x2105c6b10, 0xd, 0x2, ...)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/world.go:314 +0x354
github.com/sbinet/go-eval/pkg/eval.(*World).Compile(0x21061c240, 0x210601880, 0x2105c6b10, 0xd, 0x0, ...)
    /Users/zTrix/go/src/github.com/sbinet/go-eval/pkg/eval/world.go:281 +0x12b
main.main()
    /Users/zTrix/go/src/github.com/sbinet/go-eval/cmd/go-eval/eval.go:95 +0xb33

Still active?

Hello,

is there activity on go-eval or on the new SSA interpreter https://github.com/go-interpreter/ssainterp ?
They both they seem nice but work-in-progress, i.e. many features are not yet implemented.

I wrote my own Go interpreter https://github.com/cosmos72/gomacro before learning about these, and it's now fairly complete, so I have mixed feelings about the duplication... on one side it shows me there are other people interested in a Go interpreter, and a possibility for cooperation, on the other it could be constructed as "yet another reimplementation"

Best regards,

cosmos72

go get failed

go get github.com/sbinet/go-eval/cmd/go-eval

github.com/sbinet/go-eval/cmd/go-eval

e:\dev\golang\dev\src\github.com\sbinet\go-eval\cmd\go-eval\eval.go:80: undefined: terminal.MakeRaw
e:\dev\golang\dev\src\github.com\sbinet\go-eval\cmd\go-eval\eval.go:84: undefined: terminal.Restore

Import doesn't work

$ go-eval
:: welcome to go-eval...
> import "os"
undeclared name: sameFile
> import "fmt"
undeclared name: buffer (and 5 more errors)
> 

function with error still cause re-declaration

Here is my testing code

func foo() { return 1 }
func foo() int { return 1 }

First line will cause error of:

input:1:24: too many values for return
<none>
ideal integer

and then the next line will cause re-declaration of identifier foo
I think the identifier foo should be removed if the declaration failed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.