tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
25
Task/Runtime-evaluation/Go/runtime-evaluation.go
Normal file
25
Task/Runtime-evaluation/Go/runtime-evaluation.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"bitbucket.org/binet/go-eval/pkg/eval"
|
||||
"go/token"
|
||||
)
|
||||
|
||||
func main() {
|
||||
w := eval.NewWorld();
|
||||
fset := token.NewFileSet();
|
||||
|
||||
code, err := w.Compile(fset, "1 + 2")
|
||||
if err != nil {
|
||||
fmt.Println("Compile error");
|
||||
return
|
||||
}
|
||||
|
||||
val, err := code.Run();
|
||||
if err != nil {
|
||||
fmt.Println("Run time error");
|
||||
return;
|
||||
}
|
||||
fmt.Println("Return value:", val) //prints, well, 3
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue