Skip to content

cpp-gamedev/kalcy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3f5cc6f Ā· Oct 9, 2023

History

8 Commits
Oct 6, 2023
Oct 9, 2023
Oct 9, 2023
Oct 9, 2023
Oct 5, 2023
Oct 5, 2023
Oct 5, 2023
Oct 5, 2023
Oct 6, 2023
Oct 5, 2023
Oct 6, 2023
Oct 6, 2023
Oct 5, 2023

Repository files navigation

Arithmetic expression evaluator

kalcy is a simple expression parsing library built using C++20. In addition to numeric literals and operators, it supports an environment with customizable functions and constants.

Sample output

./kalcy-quickstart
usage: ./kalcy-quickstart [-v] "<expression>"

./kalcy-quickstart 42
42

./kalcy-quickstart -v "1 + 2 * 3 ^ 2"
19
expression      : 1 + 2 * 3 ^ 2
AST             : (1 + (2 * (3 ^ 2)))

./kalcy-quickstart -v "-2.5 * sqrt(pi)"
-4.43113
expression      : -2.5 * sqrt(pi)
AST             : (-2.5 * sqrt(pi))

Requirements

  • CMake 3.24+
  • C++20 compiler and standard library (+ runtime).

CMake

Acquire the source and add it to your project's build tree via CMake FetchContent or git clone / git submodules + add_subdirectory.

Then link to kalcy:

target_link_libraries(your-target PRIVATE kalcy::kalcy)

All required headers are included in:

#include <kalcy/kalcy.hpp>

Quickstart

Check out examples/quickstart.