Skip to content

Commit

Permalink
Add some TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler committed Dec 4, 2024
1 parent 2f9f247 commit 2bfac00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions esi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum ExecutionError {
WriterError(#[from] std::io::Error),

/// Expression parse error
// TODO: add lexer and eval errors
#[error("expression failed to parse: `{0}`")]
ExpressionParseError(String),
}
Expand Down
4 changes: 4 additions & 0 deletions esi/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::str::Chars;
use crate::{ExecutionError, Result};

pub fn evaluate_expression(raw_expr: String, ctx: EvalContext) -> Result<EvalResult> {
// TODO: this got real ugly, figure out some better way to do this
let tokens = match lex_expr(raw_expr) {
Ok(r) => r,
Err(ExecutionError::ExpressionParseError(s)) => return Ok(EvalResult::Error(s)),
Expand Down Expand Up @@ -95,6 +96,7 @@ fn lex_expr(expr: String) -> Result<Vec<Token>> {
cur.next();
result.push(get_variable(&mut cur));
}
// TODO: make these errors more useful, i.e. point to the problem
_ => return Err(ExecutionError::ExpressionParseError(expr)),
}
}
Expand All @@ -106,6 +108,7 @@ fn lex_expr(expr: String) -> Result<Vec<Token>> {
}

fn get_string(cur: &mut Peekable<Chars>) -> Token {
// TODO: handle escaping
let mut buf = Vec::new();

while let Some(c) = cur.next() {
Expand Down Expand Up @@ -189,6 +192,7 @@ mod tests {
Ok(())
}

// TODO: more negative tests
#[test]
fn test_evaluation_error() -> Result<()> {
let result = evaluate_expression(
Expand Down

0 comments on commit 2bfac00

Please sign in to comment.