-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkakapo.go
60 lines (50 loc) · 912 Bytes
/
kakapo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"flag"
"fmt"
"log"
"os"
"strings"
. "github.com/bytbox/kakapo/lisp"
)
const VERSION = `0.4`
var (
version = flag.Bool("V", false, "Display version information and exit")
)
func main() {
flag.Parse()
if *version {
fmt.Printf("Kakapo %s\n", VERSION)
return
}
// Expose imports
for name, pkg := range _go_imports {
ExposeImport(name, pkg)
}
// Expose globals
ExposeGlobal("-interpreter", "Kakapo")
ExposeGlobal("-interpreter-version", VERSION)
if len(flag.Args()) > 0 {
for _, fname := range flag.Args() {
f, err := os.Open(fname)
if err != nil {
panic(err)
}
EvalFrom(f)
}
return
}
args := flag.Args()
if len(args) == 0 {
// Start the read-eval-print loop
EvalFrom(strings.NewReader(repl))
} else {
for _, path := range args {
file, err := os.Open(path)
if err != nil {
log.Fatal(err)
}
EvalFrom(file)
}
}
}