mate-rs 0.2.0

A simple and lightweight arithmetic expression interpreter
Documentation
//
// Copyright 2022-present theiskaa. All rights reserved.
// Use of this source code is governed by MIT license
// that can be found in the LICENSE file.
//

use crate::{calculator::Calculator, errors::Error, lexer::Lexer};

// A main structure that takes string input, parses it via [Lexer],
// and calculates result via [Calculator].
pub struct Mate {}

impl Mate {
    // Takes a arithmetic expression as string, parses it to tokens, and calculates final result.
    // Detailed descriptions could be viewed at lexer source file and calculator source file.
    pub fn calculate(input: &str) -> Result<f64, Error> {
        let sub = Lexer::lex(input)?;

        Calculator::calculate(sub, input)
    }
}