123456789101112131415161718192021222324252627282930 |
- package repl
- import (
- "bufio"
- "code.osinet.fr/fgm/waiig15/lexer"
- "code.osinet.fr/fgm/waiig15/token"
- "fmt"
- "io"
- )
- const PROMPT = ">> "
- func Start(in io.Reader, out io.Writer) {
- scanner := bufio.NewScanner(in)
- for {
- fmt.Print(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)
- }
- }
- }
|