Expand description
Simple expression evaluation crate with custom lexer and parser. Currently doesn’t have support for a factorial, but this feature is in TODO list.
let result = lexper::eval("sin(2) + 20^2").unwrap();
assert_eq!(f64::round(result), 401.0);Re-exports§
pub use error::Error;
Modules§
Macros§
Structs§
- Interpreter
- Lexer
- This struct is responsible for “turning” source string into a list of tokens
Tokens makes sense only for the Parser struct - Parser
- The heart struct of the lexper. It parses the token vector into a nested AST of
Expressions. - Token
- Represents some valuable information for our Parser, operators, literals etc.
Enums§
- Expression
- Expression type, represents… an expression.
It could be everything, from just a number like2till a function call - Operator
Type - Type introduced to avoid pasting a lot of types into
TokenType, operators moved to a sub-enum, here it is. - Token
Type - The token type, literal, operator, parenthesis etc.