mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 19:21:03 +01:00
a95a02a16a
Former-commit-id: 826d7c370481b78afd9ba92f4ae8bef1fb85a567
32 lines
519 B
Go
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)
|
|
}
|
|
}
|
|
}
|