You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
519 B
Go
32 lines
519 B
Go
package repl
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"io"
|
|
|
|
"gitea.paas.celticinfo.fr/oabrivard/monkeylang/monkey1/lexer"
|
|
"gitea.paas.celticinfo.fr/oabrivard/monkeylang/monkey1/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)
|
|
}
|
|
}
|
|
}
|