Last active
February 6, 2021 18:12
-
-
Save korzio/e309dbdb361953f689018121fbb71f4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package repl | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"pizzascript/eval" | |
"pizzascript/lexer" | |
"pizzascript/parser" | |
) | |
const PROMPT = "\n>> " | |
// Start executes repl, to try PizzaScript with standard input/output | |
func Start(in io.Reader, out io.Writer) { | |
scanner := bufio.NewScanner(in) | |
for { | |
fmt.Fprintf(out, PROMPT) | |
scanned := scanner.Scan() | |
if !scanned { | |
return | |
} | |
line := scanner.Text() | |
l := lexer.New(line) | |
p := parser.New(l) | |
e := eval.New(p) | |
fmt.Println(e.Eval()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment