This crate provides a library for parsing and calculating arithmetic expressions inputted as &str(string). Uses Lexer structure to parse string in

GitHub - theiskaa/mate: A simple and lightweight math library, that can parse and calculate string expressions.

submited by
Style Pass
2022-09-22 06:30:08

This crate provides a library for parsing and calculating arithmetic expressions inputted as &str(string). Uses Lexer structure to parse string input in to token list, and Calculator structure to calculate final result from token list. Has also a general wrapper structure that implements Lexer and Calculator inside of it. And makes it easy to calculate arithmetic expression's result directly without dealing with parsing and calculating manually.

Mate is general wrapper structure for Lexer and Calculator. has only one method that used to calculate result via string(&str) input.

Lexer is the main structure that parses string-input to token-list. Calculator is the structure that used to calculate final result via Lexer's result.

Mate is all about two main structures, [Lexer] and [Calculator]. [Lexer] is the structure that takes care of parsing given string expression, and [Calculator] is the structure that takes care of calculating final result via parsed tokens

Loops through the given input string, reads and converts each character to an [Token] structure. We've several types of main tokens and they are:

Leave a Comment