Some more code
This commit is contained in:
parent
559eaf54de
commit
8749ed984d
@ -44,7 +44,6 @@ impl ProgrammingLanguageInterface for Rukka {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl EvaluatorState {
|
impl EvaluatorState {
|
||||||
fn new() -> EvaluatorState { EvaluatorState { } }
|
fn new() -> EvaluatorState { EvaluatorState { } }
|
||||||
fn eval(&mut self, expr: Sexp) -> Result<Sexp, String> {
|
fn eval(&mut self, expr: Sexp) -> Result<Sexp, String> {
|
||||||
@ -53,7 +52,19 @@ impl EvaluatorState {
|
|||||||
SymbolAtom(sym) => unimplemented!(),
|
SymbolAtom(sym) => unimplemented!(),
|
||||||
expr @ StringAtom(_) => expr,
|
expr @ StringAtom(_) => expr,
|
||||||
expr @ NumberAtom(_) => expr,
|
expr @ NumberAtom(_) => expr,
|
||||||
List(items) => unimplemented!(),
|
List(items) => {
|
||||||
|
if items.len() == 0 {
|
||||||
|
return Err(format!("Empty list"))
|
||||||
|
}
|
||||||
|
let ref first = items[0];
|
||||||
|
match first {
|
||||||
|
&SymbolAtom(ref sym) => match &sym[..] {
|
||||||
|
"quote" => unimplemented!(),
|
||||||
|
_ => unimplemented!(),
|
||||||
|
},
|
||||||
|
_ => unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,6 +173,7 @@ fn parse(tokens: &mut Peekable<IntoIter<Token>>) -> Result<Sexp, String> {
|
|||||||
|
|
||||||
fn parse_sexp(tokens: &mut Peekable<IntoIter<Token>>) -> Result<Sexp, String> {
|
fn parse_sexp(tokens: &mut Peekable<IntoIter<Token>>) -> Result<Sexp, String> {
|
||||||
use self::Token::*;
|
use self::Token::*;
|
||||||
|
use self::Sexp::*;
|
||||||
let mut vec = Vec::new();
|
let mut vec = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
match tokens.peek() {
|
match tokens.peek() {
|
||||||
@ -170,6 +182,6 @@ fn parse_sexp(tokens: &mut Peekable<IntoIter<Token>>) -> Result<Sexp, String> {
|
|||||||
_ => vec.push(parse(tokens)?),
|
_ => vec.push(parse(tokens)?),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Sexp::List(vec))
|
Ok(List(vec))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user