aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
Diffstat (limited to 'repl')
-rw-r--r--repl/face.txt13
-rw-r--r--repl/repl.go28
2 files changed, 21 insertions, 20 deletions
diff --git a/repl/face.txt b/repl/face.txt
new file mode 100644
index 0000000..14fdeb6
--- /dev/null
+++ b/repl/face.txt
@@ -0,0 +1,13 @@
+ __,__
+ .--. .-" "-. .--.
+ / .. \/ .-. .-. \/ .. \
+ | | '| / Y \ |' | |
+ | \ \ \ 0 | 0 / / / |
+ \ '- ,\.-"""""""-./, -' /
+ ''-' /_ ^ ^ _\ '-''
+ | \._ _./ |
+ \ \ '~' / /
+ '._ '-=-' _.'
+ '-----'
+
+Woops! We ran into some monkey business here!
diff --git a/repl/repl.go b/repl/repl.go
index 41bfe79..43a65f3 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -2,6 +2,7 @@ package repl
import (
"bufio"
+ _ "embed"
"fmt"
"io"
@@ -20,8 +21,7 @@ func Start(in io.Reader, out io.Writer) {
for {
fmt.Print(prompt)
- scanned := scanner.Scan()
- if !scanned {
+ if !scanner.Scan() {
return
}
@@ -46,24 +46,12 @@ func Start(in io.Reader, out io.Writer) {
}
}
-const monkeyFace = ` __,__
- .--. .-" "-. .--.
- / .. \/ .-. .-. \/ .. \
- | | '| / Y \ |' | |
- | \ \ \ 0 | 0 / / / |
- \ '- ,\.-"""""""-./, -' /
- ''-' /_ ^ ^ _\ '-''
- | \._ _./ |
- \ \ '~' / /
- '._ '-=-' _.'
- '-----'
-`
+//go:embed face.txt
+var monkeyFace string
-func printParserErrors(out io.Writer, errors []string) {
- io.WriteString(out, monkeyFace)
- io.WriteString(out, "Woops! We ran into some monkey business here!\n")
- io.WriteString(out, " parser errors:\n")
- for _, msg := range errors {
- io.WriteString(out, "\t"+msg+"\n")
+func printParserErrors(out io.Writer, errors []error) {
+ fmt.Fprintln(out, monkeyFace)
+ for _, err := range errors {
+ fmt.Fprintln(out, err)
}
}