Math::Expression::Evaluator::Util - Common functions for Math::Expression::Evaluator


NAME

Math::Expression::Evaluator::Util - Common functions for Math::Expression::Evaluator


SYNPOSIS

    use Math::Expression::Evaluator::Util qw(simplify_ast is_lvalue);
    $ast = simplify_ast($ast);
    # ...
    if (is_lvalue($ast)){
        # $ast represents an lvalue, at the moment just a variable
    }


DESCRIPTION

This is package with common functions used in the different modules in the Math::Expression::Evaluator distribution.

simplify_ast

simplify_ast takes a reference to an AST, and returns a simplified version. It just prunes no-op AST nodes and flattens the AST.

For example it turns ['*', [@foo]] into [@foo] for arbitrary values of @foo.

For a description of the AST see the Math::Expression::Evaluator::Parser manpage.

is_lvalue

is_lvalue($ast) checks if (a simplified version of) $ast represents something that can be assigned to, i.e. is a variable.