lexper 0.0.3

A simple CLI calculator with a handwritten lexer and parser in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Simple macro to insert variables into an expression in compile-time via [`format!`] macro
///
/// ## Example usage
/// ```
/// use lexper::eval;
/// let result = lexper::eval!("{} + {} - {}", 5, 1, 3).unwrap();
/// assert_eq!(result, 3.0);
/// ```
#[macro_export]
macro_rules! eval {
    ($fmt:literal, $($arg:expr),*) => {{
        let expr_string = format!($fmt, $($arg),*);
        lexper::eval(&expr_string)
    }};
}