Skip to content

Releases: sillydan1/expr

v1.1.3

06 Mar 10:08
Compare
Choose a tag to compare

EXPR Release v1.1.3

The parser rules now have two different modes:

  1. Either evaluate a string of assignment expressions e.g. a := 1; b := 2 or
  2. Evaluate a single expression with result stored in driver.result["expression_result"]

latest tag now points to the latest stable release

If you want to use the project in your own cmake project, simply include expr as a subdirectory and link
with the libexpr library. The project is also tagged with release versions to be compatible with cpm,
so if your project uses that, simply include the project like so:

CPMAddPackage("gh:sillydan1/expr#latest")

v1.0.0

05 Mar 12:47
9b2f35b
Compare
Choose a tag to compare

expr Release v1.0.0

A variable environment manipulation expression parser written in C++20 with flex and bison.

Examples

This project comes with an demo example command line interface called expr_demo so that you
can test if the project supports your expression syntax. This example cli can

./expr_demo -
a := (1 + 2 + 3 + 4);
b := one + two;
^D
a :-> 6 i
b :-> 3 i

You can also use the project directly in code like so:

try {                               // Errors are handled with exceptions
    symbol_map_t env{};             // Initialize an environment
    driver drv{env};                // Initialize the expr driver with the environment
    if (!drv.parse("a := 32 + 2"))  // Parse your expressions
        std::cout << drv.result;    // Print the result
} catch(const std::exception& e) {  // Parsing went wrong. Maybe bad syntax, type error or identifier not in environment
    std::cout << e.what();          // Print what went wrong
}

Compile

You should be able to compile with cmake like so:

mkdir bin && cd bin
cmake ..
make