This commit is contained in:
Tommy Parnell
2017-12-30 16:14:51 -05:00
commit 725e4dc5bf
9 changed files with 598 additions and 0 deletions

30
repl/repl.go Normal file
View File

@@ -0,0 +1,30 @@
package repl
import (
"bufio"
"fmt"
"io"
"monkey/lexer"
"monkey/token"
)
const PROMPT = ">> "
func Start(in io.Reader, out io.Writer) {
scanner := bufio.NewScanner(in)
for {
fmt.Printf(PROMPT)
scanned := scanner.Scan()
if !scanned {
return
}
line := scanner.Text()
l := lexer.New(line)
for tok := l.NextToken(); tok.Type != token.EOF; tok = l.NextToken() {
fmt.Printf("%+v\n", tok)
}
}
}