From 8d2a65b44e8fbb62ff6dd2fd34e5ffe2e4e3a266 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 30 Sep 2017 23:30:02 -0700 Subject: [PATCH] Starting eval framework --- src/schala_lang/eval.rs | 15 +++++++++++++++ src/schala_lang/mod.rs | 8 ++++++-- src/schala_lang/parsing.rs | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/schala_lang/eval.rs diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs new file mode 100644 index 0000000..08d203b --- /dev/null +++ b/src/schala_lang/eval.rs @@ -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) + } +} + diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index b092003..0c28338 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -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; } diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index 70e2ff3..ddc62a1 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -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)