How do you parse a mathematical formula in Delphi? Interpreted languages make expression evaluation make it easy. But what about compiled applications? Parsing mathematical expressions is a challenge in computer programming. Innocent looking expressions such as "sin(x)/cos(y)" can be notoriously hard and frustrating to develop and test. Luckily, this is now a solved problem. Thanks to parsers from Bestcode .com, Delphi, C++ Builder, .NET, Visual Studio, C++, COM and C++ developers are all covered with the time proven and tested features of math parser components.

TbcParser is a mathematical expression parser VCL (Visual Component Library) component that can be used with Delphi and C++ Builder 4,5,6,7, 2006, 2007, 2009 2010, XE and XE2.

TbcParser VCL Component features include:

Easy to use component Programming API.
Comes with predefined functions.
You can create custom functions/variables and get a callback to your own functions that you define in your source code.
Optimization: Constant expression elimination for repeated tasks.
Logical Operators: <, >, =, &, |, !, <>, <=, >=
Analytic Operators: +, -, /, *, ^
Paranthesis: (, {, [
Functions in the form of: f(x,y,z,...)
List of predefined functions is available in the math parser documentation.
Royalty free distribution.
Source code is included.
Figure: Drag Drop on your Delphi or C++ Builder Form as shown below:

TbcParser is useful in financial, scientific, engineering programs. One can use the math parser in a speadsheet application like Excel.

It’s internal arithmetic uses ‘Extended’ Delphi storage type for floating point numbers.

To be efficient in repeated calculations, parser creates a parse tree at first and reuses this parse tree for each evaluation without the need to reparse. If Optimization is on, the parse tree will be optimized by calculating constant expression sections at once so that further evaluation requests will be quicker without the need to re-evaluate those sub trees.

TbcParser math parser component comes with the Pascal source code and there is also a help file for reference and a demo application for aid in getting started. So it is easy to make it work with different versions of Delphi or C++ Builder in the future.