iris/_future/ipel/repl/repl.go
Gerasimos (Makis) Maropoulos a95a02a16a Nothing special here (yet)
Former-commit-id: 826d7c370481b78afd9ba92f4ae8bef1fb85a567
2017-03-27 04:09:44 +03:00

32 lines
519 B
Go

package repl
import (
"bufio"
"fmt"
"io"
"gopkg.in/kataras/iris.v6/_future/ipel/lexer"
"gopkg.in/kataras/iris.v6/_future/ipel/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()
if line == "exit" {
break
}
l := lexer.New(line)
for tok := l.NextToken(); tok.Type != token.EOF; tok = l.NextToken() {
fmt.Printf("%+v\n", tok)
}
}
}