pub fn run_interactive(frame: Frame, bindings: SymbolBindings) {
    println!("{} version {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
    println!("Interactive interpreter");

    let mut frame               = frame;
    let mut bindings            = bindings;
    let mut monad_value         = NIL.clone();

    loop {
        // Read a line
        let mut input = String::new();
        println!();
        print!("-> ");
        io::stdout().flush().unwrap();
        let num_bytes = io::stdin().read_line(&mut input).unwrap();

        // EOF if num_bytes = 0
        if num_bytes == 0 {
            break;
        }

        // Parse the input
        let input = parse_safas(&mut TokenReadBuffer::new(input.chars()), FileLocation::new("<stdin>"));
        let input = match input {
            Ok(input)   => input,
            Err(error)  => {
                println!("!! Parse error: {:?}", error);
                continue;
            }
        };

        // Evaluate the frame
        let (result, next_bindings, next_frame) = eval_statements(input, monad_value, bindings, frame);

        // Display the next result
        match &*result {
            SafasCell::Error(err)   => println!("!! Error: {:?}", err),
            _                       => println!("{}", result.to_string())
        }

        // Update to the next result
        frame       = next_frame;
        bindings    = next_bindings;
        monad_value = result;
    }
}
///
/// Runs the parser and interpreter in interactive mode, displaying the results to the user
///
Runs the parser and interpreter in interactive mode, displaying the results to the user
Runs the parser and interpreter in interactive mode displaying the results to the user
pub fn run_interactive(frame: Frame, bindings: SymbolBindings) {
    println!("{} version {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
    println!("Interactive interpreter");
    let mut frame               = frame;
    let mut bindings            = bindings;
    let mut monad_value         = NIL.clone();
    loop {
        // Read a line
        let mut input = String::new();
        println!();
        print!("-> ");
        io::stdout().flush().unwrap();
        let num_bytes = io::stdin().read_line(&mut input).unwrap();
        // EOF if num_bytes = 0
        if num_bytes == 0 {
            break;
        }
        // Parse the input
        let input = parse_safas(&mut TokenReadBuffer::new(input.chars()), FileLocation::new("<stdin>"));
        let input = match input {
            Ok(input)   => input,
            Err(error)  => {
                println!("!! Parse error: {:?}", error);
                continue;
            }
        };
        // Evaluate the frame
        let (result, next_bindings, next_frame) = eval_statements(input, monad_value, bindings, frame);
        // Display the next result
        match &*result {
            SafasCell::Error(err)   => println!("!! Error: {:?}", err),
            _                       => println!("{}", result.to_string())
        }
        // Update to the next result
        frame       = next_frame;
        bindings    = next_bindings;
        monad_value = result;
    }
}
pub fn run_interactive ( frame : Frame , bindings : SymbolBindings ) { println ! ( " " env ( " " ) env ( " " ) ) ; println ! ( " " ) ; let mut frame = frame ; let mut bindings = bindings ; let mut monad_value = NIL . clone ( ) ; loop { // Read a line let mut input = String :: new ( ) ; println ! ( ) ; print ! ( " " ) ; io :: stdout ( ) . flush ( ) . unwrap ( ) ; let num_bytes = io :: stdin ( ) . read_line ( & mut input ) . unwrap ( ) ; // EOF if num_bytes = 0 if num_bytes == 0 { break ; } // Parse the input let input = parse_safas ( & mut TokenReadBuffer :: new ( input . chars ( ) ) , FileLocation :: new ( " " ) ) ; let input = match input { Ok ( input ) => input , Err ( error ) => { println ! ( " " error ) ; continue ; } } ; // Evaluate the frame let ( result , next_bindings , next_frame ) = eval_statements ( input , monad_value , bindings , frame ) ; // Display the next result match & * result { SafasCell :: Error ( err ) => println ! ( " " err ) , _ => println ! ( " " result to_string ( ) ) } // Update to the next result frame = next_frame ; bindings = next_bindings ; monad_value = result ; } }
Runs the parser and interpreter in interactive mode, displaying the results to the user
Runs the parser and interpreter in interactive mode displaying the results to the user
frame
Frame
bindings
SymbolBindings
frame
Frame
bindings
SymbolBindings