aboutsummaryrefslogtreecommitdiff
path: root/repl/repl.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-02-17 23:50:45 -0500
committerBobby <[email protected]>2024-02-17 23:50:45 -0500
commita18137bab2c53655168be9856e28de8c29232994 (patch)
tree9dc1ebbe8e49e97846f944a2e04e017f5dc267e6 /repl/repl.go
parentb3d5ef5c6c3dcb6d1bf707b82e5350168d66d6c5 (diff)
downloadmana-a18137bab2c53655168be9856e28de8c29232994.tar.xz
mana-a18137bab2c53655168be9856e28de8c29232994.zip
Added Evaulator and Object Model
Diffstat (limited to 'repl/repl.go')
-rw-r--r--repl/repl.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/repl/repl.go b/repl/repl.go
index 9db9683..9a43119 100644
--- a/repl/repl.go
+++ b/repl/repl.go
@@ -6,11 +6,12 @@ import (
"io"
"mana/lexer"
"mana/parser"
+ "mana/evaluator"
)
// PROMPT is the prompt for the REPL.
const PROMPT = ">>> "
-const MANA_ICON = `
+const MANA_START = `
███╗░░░███╗░█████╗░███╗░░██╗░█████╗░
████╗░████║██╔══██╗████╗░██║██╔══██╗
██╔████╔██║███████║██╔██╗██║███████║
@@ -21,7 +22,7 @@ const MANA_ICON = `
func Start(in io.Reader, out io.Writer) {
var scanner *bufio.Scanner = bufio.NewScanner(in)
- io.WriteString(out, MANA_ICON + "\n")
+ io.WriteString(out, MANA_START + "\n")
for {
fmt.Fprint(out, PROMPT)
@@ -42,13 +43,16 @@ func Start(in io.Reader, out io.Writer) {
continue
}
- io.WriteString(out, program.String())
- io.WriteString(out, "\n")
+ evaluated := evaluator.Eval(program)
+ if evaluated != nil {
+ io.WriteString(out, evaluated.Inspect())
+ io.WriteString(out, "\n")
+ }
}
}
func printParserErrors(out io.Writer, errors []string) {
- io.WriteString(out, "Mana Encountered Parser Errors:\n")
+ io.WriteString(out, "ParseError:\n")
for _, msg := range errors {
io.WriteString(out, "\t" + msg + "\n")
}