Still tryign to make the pointer-munging work
This commit is contained in:
parent
9273773bf4
commit
f8152f68ad
@ -74,7 +74,7 @@ impl EvaluatorState {
|
|||||||
"define" => unimplemented!(),
|
"define" => unimplemented!(),
|
||||||
"lambda" => unimplemented!(),
|
"lambda" => unimplemented!(),
|
||||||
"cond" => unimplemented!(),
|
"cond" => unimplemented!(),
|
||||||
x => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
},
|
},
|
||||||
other => {println!("OTHER? {:?}", other); unimplemented!() }
|
other => {println!("OTHER? {:?}", other); unimplemented!() }
|
||||||
}
|
}
|
||||||
@ -189,12 +189,27 @@ fn parse_sexp(tokens: &mut Peekable<IntoIter<Token>>) -> Result<Sexp, String> {
|
|||||||
use self::Token::*;
|
use self::Token::*;
|
||||||
use self::Sexp::*;
|
use self::Sexp::*;
|
||||||
let mut cell = Nil;
|
let mut cell = Nil;
|
||||||
loop {
|
{
|
||||||
match tokens.peek() {
|
let mut cell_ptr = &mut cell;
|
||||||
None => return Err(format!("Unexpected end of input")),
|
loop {
|
||||||
Some(&RParen) => { tokens.next(); break},
|
match tokens.peek() {
|
||||||
_ => {
|
None => return Err(format!("Unexpected end of input")),
|
||||||
cell = Cons(Box::new(cell), Box::new(parse(tokens)?));
|
Some(&RParen) => {
|
||||||
|
tokens.next();
|
||||||
|
break;
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
let current = parse(tokens)?;
|
||||||
|
let new_cdr = Cons(Box::new(current), Box::new(Nil));
|
||||||
|
match cell_ptr {
|
||||||
|
&mut Cons(_, ref mut cdr) => **cdr = new_cdr,
|
||||||
|
&mut Nil => *cell_ptr = new_cdr,
|
||||||
|
_ => unreachable!()
|
||||||
|
};
|
||||||
|
|
||||||
|
//let new_ptr: &Sexp = match cell_ptr { &mut Cons(_, ref cdr) => cdr, _ => unreachable!() } as &Sexp;
|
||||||
|
//cell_ptr = new_ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user