pub mod apply;
pub(crate) mod pair;
pub(crate) mod plugin;
mod sentence;
use crate::{
Environment,
eval::{apply::eval_apply, sentence::eval_sentence},
token::{TokenType, source_to_token},
value::Value,
};
pub fn eval(source: &str, env: Environment) -> Result<Value, std::sync::Arc<str>> {
let mut current_val = Value::Unit;
for sentence in source_to_token(source)?
.split(|token| matches!(token.value, TokenType::SentenceSeperator))
.filter(|s| !s.is_empty())
{
current_val = eval_sentence(sentence, env.clone()).and_then(|val| eval_apply(&val, env.clone()))?;
}
Ok(current_val)
}