Function rust_lisp::parser::parse

source ·
pub fn parse(code: &str) -> impl Iterator<Item = Result<Value, ParseError>> + '_
Expand description

Parse a string of Lisp code into a series of s-expressions. There are more than one expressions when the base string has more than one independent parenthesized lists at its root.

Examples found in repository?
src/lib.rs (line 28)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
pub fn start_repl(env: Option<Env>) {
    let env_rc = Rc::new(RefCell::new(env.unwrap_or_else(default_env)));

    print!("> ");
    io::stdout().flush().unwrap();
    for line in io::stdin().lock().lines() {
        match interpreter::eval_block(
            env_rc.clone(),
            parser::parse(&line.unwrap()).filter_map(|a| a.ok()),
        ) {
            Ok(val) => println!("{}", val),
            Err(e) => println!("{}", e),
        };

        print!("> ");
        io::stdout().flush().unwrap();
    }

    // Properly go to the next line after quitting
    println!();
}