Skip to content

Instantly share code, notes, and snippets.

@korzio
Last active February 6, 2021 18:12
Show Gist options
  • Save korzio/e309dbdb361953f689018121fbb71f4d to your computer and use it in GitHub Desktop.
Save korzio/e309dbdb361953f689018121fbb71f4d to your computer and use it in GitHub Desktop.
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