package repl import ( "bufio" "code.osinet.fr/fgm/waiig15/lexer" "code.osinet.fr/fgm/waiig15/token" "fmt" "io" ) // PROMPT is the prompt shown to the user of the REPL to invite them to type // some code. const PROMPT = ">> " // Start implements the Read-Eval-Print Loop. 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) } } }