calculate method
Takes user-input string expression, parses it by using Lexer
,
and then calculates final result with Expression
.
Implementation
double? calculate(String exp) {
if (isInvalidExp(exp)) return null;
final List<Token> parts = lexer.parse(exp);
expression.parts = parts;
// Log tokens/parts tree, if debug mode was enabled.
if (debugMode) logTree(parts);
return expression.calculate();
}