-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
33 lines (28 loc) · 810 Bytes
/
main.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
// Copyright 2011 Vadim Vygonets. All rights reserved.
// Use of this source code is governed by the Bugroff
// license that can be found in the LICENSE file.
/*
Forego is a FORTH system.
Forego runs the Forego virtual machine with the default kernel
using stdin and stdout for I/O. Unless the VM stops due to BYE
being executed, Forego prints the trap description on stderr and
exits with error code 1.
*/
package main
import (
"fmt"
"os"
"github.com/unixdj/forego/forth"
)
func main() {
if err := forth.NewVM(os.Stdin, os.Stdout).Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
if fe := err.(*forth.Error); fe.Errno != forth.EOF {
fmt.Fprintf(os.Stderr,
"instruction: %v <%v>\nstack: %v\nrstack: %v\n",
fe.Instr, forth.Cell(fe.Instr),
fe.Stack, fe.RStack)
}
os.Exit(1)
}
}