From f130bed7aa86c5f77ebde822b39dc94a648f93c0 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 3 Aug 2023 13:56:50 -0700 Subject: [PATCH] Added incomplete flag --- src/entry/unix/unix.rs | 4 ++-- src/evaluate/evaluate.rs | 13 +++++++++++-- src/tests.rs | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/entry/unix/unix.rs b/src/entry/unix/unix.rs index 8d690a3..d4d54f0 100644 --- a/src/entry/unix/unix.rs +++ b/src/entry/unix/unix.rs @@ -15,7 +15,7 @@ use termion::{ use super::promptbuffer::PromptBuffer; use crate::parser; use crate::command; -use crate::evaluate::evaluate; +use crate::evaluate; use crate::context::Context; use crate::parser::substitute; @@ -69,7 +69,7 @@ fn do_expression( // Evaluate expression #[cfg(debug_assertions)] RawTerminal::suspend_raw_mode(&stdout).unwrap(); - let g_evaluated = evaluate(&g, context); + let g_evaluated = evaluate::evaluate(&g, context, false); #[cfg(debug_assertions)] RawTerminal::activate_raw_mode(&stdout).unwrap(); diff --git a/src/evaluate/evaluate.rs b/src/evaluate/evaluate.rs index 9544ed2..d18ee3b 100644 --- a/src/evaluate/evaluate.rs +++ b/src/evaluate/evaluate.rs @@ -7,7 +7,7 @@ use super::operator::eval_operator; use super::function::eval_function; use super::EvalError; -pub fn evaluate(t: &Expression, context: &mut Context) -> Result { +pub fn evaluate(t: &Expression, context: &mut Context, allow_incomplete: bool) -> Result { // Keeps track of our position in the expression tree. // For example, the coordinates [0, 2, 1] are interpreted as follows: @@ -44,7 +44,7 @@ pub fn evaluate(t: &Expression, context: &mut Context) -> Result None, - Expression::Constant(_, c) => { Some(evaluate(&c.value(), context).unwrap()) }, + Expression::Constant(_, c) => { Some(evaluate(&c.value(), context, false).unwrap()) }, Expression::Variable(l, s) => { // Don't move up, re-evaluate // This makes variables containing floating variables work properly @@ -71,6 +71,15 @@ pub fn evaluate(t: &Expression, context: &mut Context) -> Result Result { }; //let out_str = g.print(); - return match evaluate(&g, &mut Context::new()) { + return match evaluate(&g, &mut Context::new(), false) { Ok(x) => Ok(x.to_string_outer()), Err(_) => Err(()) };