docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
A utility that processes and evaluates mathematical formulas from user input with variable substitution support.
type property @test{x: 5, y: 3} returns 8 @test{a: 3, b: 4} returns 5 @test{x: 5} returns 10 @test/**
* Parses a mathematical expression string into an abstract syntax tree.
*
* @param {string} expression - The mathematical expression to parse
* @returns {object} An object representing the parsed expression tree
*/
function parseExpression(expression) {
// IMPLEMENTATION HERE
}
/**
* Evaluates a mathematical expression with the given variable values.
*
* @param {string} expression - The mathematical expression to evaluate
* @param {object} variables - An object containing variable values
* @returns {number} The result of the evaluation
*/
function evaluateExpression(expression, variables) {
// IMPLEMENTATION HERE
}
/**
* Compiles a mathematical expression for efficient repeated evaluation.
*
* @param {string} expression - The mathematical expression to compile
* @returns {object} A compiled expression object with an evaluate method
*/
function compileExpression(expression) {
// IMPLEMENTATION HERE
}
/**
* Creates a persistent parser that maintains state between evaluations.
*
* @returns {object} A parser object with an evaluate method
*/
function createPersistentParser() {
// IMPLEMENTATION HERE
}
module.exports = {
parseExpression,
evaluateExpression,
compileExpression,
createPersistentParser
};Provides mathematical expression parsing and evaluation capabilities.