TinyExpr++

User Reference & Programming Manual

Author

Blake Madden

Published

March 24, 2024

This book is the guide to using the TinyExpr++ library, a C++ formula parsing and evaluation system.

This book is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International License.

Overview

This is the programming manual for TinyExpr++, the C++ version of the TinyExpr (Winkle) formula parsing library. (This manual includes documentation from TinyExpr by Lewis Van Winkle.)

TinyExpr++ is a small parser and evaluation library for solving math expressions from C++. It’s open-source, free, easy-to-use, and self-contained in a single source and header file pair.

Features

  • C++17 with no dependencies.
  • Single source file and header file.
  • Simple and fast.
  • Implements standard operator precedence.
  • Implements logical and comparison operators.
  • Exposes standard C math functions (sin, sqrt, ln, etc.), as well as some Excel-like functions (e.g., AVERAGE() and IF()).
  • Can add custom functions and variables easily.
  • Can add a custom handler to resolve unknown variables.
  • Can bind constants at eval-time.
  • Supports variadic functions (taking between 1-7 arguments).
  • Case insensitive.
  • Supports non-US formulas (e.g., POW(2,2; 2) instead of POW(2.2, 2)).
  • Supports C and C++ style comments within math expressions.
  • Can be configured to use double, long double, or float for its calculations.
  • Released under the zlib license - free for nearly any use.
  • Easy to use and integrate with your code.
  • Thread-safe; parser is in a self-contained object.