1pub mod apply;
6pub(crate) mod pair;
7pub(crate) mod plugin;
8mod sentence;
9
10use crate::{
11 Environment,
12 eval::{apply::eval_apply, sentence::eval_sentence},
13 token::{TokenType, source_to_token},
14 value::Value,
15};
16
17pub fn eval(source: &str, env: Environment) -> Result<Value, std::sync::Arc<str>> {
34 let mut current_val = Value::Unit;
35 for sentence in source_to_token(source)?
36 .split(|token| matches!(token.value, TokenType::SentenceSeperator))
37 .filter(|s| !s.is_empty())
38 {
39 current_val = eval_sentence(sentence, env.clone()).and_then(|val| eval_apply(&val, env.clone()))?;
40 }
41 Ok(current_val)
42}