CSMic 2.0.2
dotnet add package CSMic --version 2.0.2
NuGet\Install-Package CSMic -Version 2.0.2
<PackageReference Include="CSMic" Version="2.0.2" />
<PackageVersion Include="CSMic" Version="2.0.2" />
<PackageReference Include="CSMic" />
paket add CSMic --version 2.0.2
#r "nuget: CSMic, 2.0.2"
#:package CSMic@2.0.2
#addin nuget:?package=CSMic&version=2.0.2
#tool nuget:?package=CSMic&version=2.0.2
CSMic
CSMic is the core CS-MIC package. It provides the expression parser, interpreter runtime, variable storage, array support, expression bindings, soft-error reporting, and the custom function API.
Install it when you want the parser and runtime without the optional standard-library functions.
dotnet add package CSMic
What It Provides
InputInterpreter, the main API for parsing and evaluating input.- Numeric expression support for arithmetic, powers, modulus, parentheses, comparisons, implicit multiplication, decimal literals, hexadecimal literals, and binary literals.
- Persistent interpreter state for numeric variables, expression variables, and numeric arrays.
- Soft-error behavior through
StringValueinstead of throwing for normal parse and evaluation failures. ICodedFunction,FunctionArgument, andFunctionValuefor host-provided functions.
Basic Usage
using CSMic;
var interpreter = new InputInterpreter();
decimal result = interpreter.Interpret("2 + 3 * 4");
// result == 14
Interpret returns the latest numeric value and updates these properties:
NumericValue: the numeric result of the latest successful expression, or0for a soft error.StringValue: empty for a successful numeric expression, or an error message for a soft error.LastExecutionTime: elapsed time for the latest interpretation.Variables: the current numeric, expression, and array variables.
Variables
Numeric variables use ::.
interpreter.Interpret("x :: 4");
interpreter.Interpret("x + 1"); // 5
Expression variables use := and are evaluated when referenced.
interpreter.Interpret("x :: 2");
interpreter.Interpret("y := x + 1");
interpreter.Interpret("y"); // 3
interpreter.Interpret("x :: 5");
interpreter.Interpret("y"); // 6
Numeric arrays use -> and zero-based indexes.
interpreter.Interpret("values -> [1, 2, 3]");
interpreter.Interpret("values[2]"); // 3
Custom Functions
Implement ICodedFunction and register it with the interpreter.
using CSMic;
public sealed class Square : ICodedFunction
{
public string Name => "square";
public IEnumerable<FunctionArgument> ExpectedArguments =>
new[] { new FunctionArgument("value", FunctionValue.NUMBER) };
public FunctionValue ReturnValue => FunctionValue.NUMBER;
public FunctionValue Execute(params FunctionArgument[] args)
{
var value = (decimal)args[0].Value.Value!;
return new FunctionValue(FunctionValueType.Numeric, value * value);
}
}
var interpreter = new InputInterpreter();
interpreter.RegisterFunction(new Square());
interpreter.Interpret("square(5)"); // 25
Functions can accept numeric and string arguments. String literals are only valid in function argument positions; general expression results remain numeric-first.
When To Use This Package
Use CSMic directly when your application owns the function set, wants a small expression runtime, or needs to keep end-user functions tightly scoped to your domain.
Use CSMic.StandardLibrary when you also want ready-made constants and common math functions.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CSMic:
| Package | Downloads |
|---|---|
|
CSMic.StandardLibrary
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.