Starting eval framework

This commit is contained in:
greg 2017-09-30 23:30:02 -07:00
parent 6b9fee1aed
commit 8d2a65b44e
3 changed files with 22 additions and 3 deletions

15
src/schala_lang/eval.rs Normal file
View File

@ -0,0 +1,15 @@
use schala_lang::parsing::AST;
pub struct ReplState {
}
impl ReplState {
pub fn new() -> ReplState {
ReplState { }
}
pub fn evaluate(&mut self, ast: AST) -> String {
format!("Evaluated AST: {:?}", ast)
}
}

View File

@ -2,13 +2,17 @@ use itertools::Itertools;
use language::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, ReplOutput};
mod parsing;
mod eval;
pub struct Schala {
state: eval::ReplState
}
impl Schala {
pub fn new() -> Schala {
Schala { }
Schala {
state: eval::ReplState::new(),
}
}
}
@ -49,7 +53,7 @@ impl ProgrammingLanguageInterface for Schala {
}
};
let evaluation_output = format!("{:?}", ast);
let evaluation_output = self.state.evaluate(ast);
output.add_output(evaluation_output);
return output;
}

View File

@ -620,7 +620,7 @@ impl Parser {
_ => None
};
if let Some(a) = expr_body.1 {
panic!("UNexpected thing {:?}", a);
return ParseError::new("Bad parse state");
}
expr_body.1 = type_anno;
Ok(expr_body)