CS-MIC

Build status
Test status

CS-MIC is a small embeddable expression interpreter for .NET applications.

It is built for software that needs to accept flexible numeric input from users while keeping evaluation controlled, deterministic, and easy to extend from host code.

What changed in v2

Version 2 separates the project into two NuGet packages:

  • CSMic provides the core parser, interpreter runtime, variable storage, array support, expression bindings, soft-error reporting, and custom function API.
  • CSMic.StandardLibrary adds optional constants and common math functions on top of the core interpreter.

This split keeps the core package small while making the convenience library available for applications that want built-in math helpers.

Install

Install the core interpreter when your application will provide its own function set:

dotnet add package CSMic

Install the standard library when you also want built-in constants and math functions:

dotnet add package CSMic.StandardLibrary

CSMic.StandardLibrary depends on CSMic, so most applications that use the standard library only need to install CSMic.StandardLibrary.

See Installation for package details.

Quick Example

using CSMic;

var interpreter = new InputInterpreter();

decimal result = interpreter.Interpret("2 + 3 * 4");
// result == 14

With the standard library:

using CSMic;
using CSMic.StandardLibrary;

var interpreter = new InputInterpreter();
Initializer.InitializeAll(interpreter);

decimal area = interpreter.Interpret("pi * 10^2");
decimal angle = interpreter.Interpret("degrees(pi / 2)");

Core Features

  • Arithmetic expressions with familiar precedence rules.
  • Decimal, hexadecimal, and binary numeric literals.
  • Numeric variables, expression bindings, and numeric arrays.
  • Numeric comparisons that return 1 for true and 0 for false.
  • Host-defined functions through ICodedFunction.
  • Soft parse/runtime errors through StringValue instead of normal exceptions.
  • netstandard2.1 target for broad .NET compatibility.

When To Use CS-MIC

Use CS-MIC when users need to type expressions such as:

(basePrice * quantity) * 1.0825

or:

max(0, sensorValue - offset)

and your application needs to control which variables and functions exist.

CS-MIC is not a general-purpose scripting engine. It is intentionally focused on numeric expression evaluation and host-controlled extension points.

Documentation

Source

The canonical source repository is:

https://git.jordanwages.com/wagesj45/cs-mic

Use that repository for source code, issues, build status, release history, and project decisions.