I discovered the beauty and elegance of expression evaluators a number of years ago when I needed to develop an easy to use report generation module for a commercial software product using flat files — yes, it was before the widespread availability of SQL servers for desktop PCs.
Given a set of files and the relationships between the files, I needed a simple way to define reports that allowed the user to specify what fields to include, calculate new field data, select the relevant rows, and then sort that data for output. I was able to quickly pull all this together by creative uses of an expression evaluator.
An expression evaluator is a software tools that takes a string expression, parses it, and returns the result. For example, passing the string “123/5+1.5” to the evaluator would return “36.9”.
I have written a number evaluators over the years and the one that is presented here is one of the most flexible ones yet. It supports four data types (string, number, boolean, and date) as well as a number of logical operators and functions.
You can find the code and examples on GitHub at expression-evaluator.