main.go (527B)
1 package main 2 3 import ( 4 "fmt" 5 "umx_compiler/repl" 6 "os" 7 "os/user" 8 _ "bsandro.tech/umx_asm.git/asm" 9 ) 10 11 func main() { 12 user, err := user.Current() 13 if err != nil { 14 panic(err) 15 } 16 17 if len(os.Args) > 1 { 18 fname := os.Args[1] 19 script, err := os.ReadFile(fname) 20 if err != nil { 21 fmt.Printf("error opening file %s: %s\n", fname, err.Error()) 22 return 23 } 24 repl.Run(string(script), os.Stdout) 25 } else { 26 fmt.Printf("ehlo %s, this is 'Monkey' language interpreter\n", user.Username) 27 repl.Start(os.Stdin, os.Stdout) 28 } 29 }