-
Notifications
You must be signed in to change notification settings - Fork 4
/
basic.rs
31 lines (24 loc) · 1.07 KB
/
basic.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extern crate lichen;
use lichen::parse::Parser;
use lichen::var::Var;
use lichen::eval::Evaluator;
fn main() {
//load the lichen source file as a string
let bytes = include_bytes!("basic.ls");
let mut src = String::from_utf8_lossy(bytes);
let mut env = Parser::parse_blocks(src.to_mut()).expect("ERROR: Unable to parse source").into_env(); //parse the source and build the environment
let mut ev = Evaluator::new(&mut env); // build the evaluator based on the environment
while let Some((vars, _next_node)) = ev.next() { // here we loop through the evaluator steps
for var in vars {
match var {
Var::String(s) => { println!("{:}", s); }, // print out the emitted variables
_ => {},
}
}
// if we wanted to we could look at the next_node returned,
// and advance it manually if needed
// you'd do this if the node were an await-style node,
// which either advances or continues on during the next step
// see the contrived example to see this
}
}