Formula.Parser 1.1.0

dotnet add package Formula.Parser --version 1.1.0
NuGet\Install-Package Formula.Parser -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Formula.Parser" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Formula.Parser --version 1.1.0
#r "nuget: Formula.Parser, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Formula.Parser as a Cake Addin
#addin nuget:?package=Formula.Parser&version=1.1.0

// Install Formula.Parser as a Cake Tool
#tool nuget:?package=Formula.Parser&version=1.1.0

formula

A simple extensible formula language for .NET

Syntax

  • Arithmetic: + - * % / ^ ( )
  • Functions: FunctionName(Parameter, Parameter, ...)
  • Variables: VariableName OR [Variable Name With Spaces]
    • Ranges: VariableName|LowerExpr:UpperExpr| OR [Variable Name With Spaces]|LowerExpr:UpperExpr|
    • Indices: VariableName|IndexExpr| OR [Variable Name With Spaces]|IndexExpr|
  • Constants:
    • Number: 123.0
    • Boolean: true/false
    • Text: "A string"
    • Nothing: null
  • Branching: IF Expr THEN Expr ELSE Expr
  • Logical: = <> > < >= ⇐ ! && ||

Examples

  • (1 + 2) * 3
  • SQRT(16)
  • MyVar * 2

Usage

  • From C#
    • CsWrapper.InterpretFormula("Test * 2", new Dictionary<string, double>() { { "Test", 1 } }, DefaultFunctionProvider.Instance)
    • CsWrapper.ParseFormula("Test * 2")
  • From F#
    • Formula.Parser.Parser.parseFormulaString
    • Formula.Parser.Interpreter.interpretFormula

Version History

1.1.0

  • IL emit based compiler
  • ExtractExpressionDependenciesWithRanges bug fix for partially resolved ranges

1.0.0

  • Bug fix for large expressions

0.13.0

  • Constant folder supports folding functions with constant arguments
    • Function implementations can declare they are deterministic
    • EmptyFunctionProvider created
  • Implicit cast from nullables fix/improvement

0.12.0

  • Support for 'Nothing' data type
    • Compiler & interpreter return an Option float value
    • C# wrapper returns Nullable<double>
    • Handling of Nothing values in aggregation functions
  • IFunctionProvider returns typed results
  • 'null' keyword added

0.11.0

  • Parser detection of ranges used outside of function parameters
  • Remove implicit use of the first range value in operations

0.10.1

  • Bug fix for duplicate dependencies being returned from DependencyExtractor

0.10.0

  • Syntax support for offsets/indices on variables e.g. MyVar|1|
  • FIRST, LAST, MIN, MAX functions
  • Added FunctionValidator to validate function calls after parsing

0.9.0

  • Support escaped characters in string literals
  • Missing dependencies reported from dependency extractor with function defined ranges

0.8.0

  • Better parser error reporting - new ParserException
  • Position information reported from parser
  • Position information reported by dependency extractor

0.7.0

  • Syntax support for ranges on variables e.g. MyVar|1:5|
  • Range support for variable providers
  • Range dependency information
  • SUM, AVG functions

0.6.0

  • Typing changes to allow for typed function parameters - number, boolean, text

0.5.1

  • Target .NETStandard 2.0

0.5.0

  • Syntax changes
    • Support for escaping identifiers between []
    • Change function parameters to use ()

0.4.0

  • Financial functions
  • Dependency extractor
  • Composite IVariableProvider
  • Mutable IVariableProvider
  • Testing enhancements

0.3.0

  • Expression compiler
  • Branching & logical operators
  • Expression based IVariableProvider
  • Composite IFunctionProvider

0.2.0

  • Extension points for functions and variables
    • IFunctionProvider
    • IVariableProvider
  • Modulus function & operator
    • MOD
    • %

0.1.0

  • Support basic arithmetic
    • Addition/Subtraction
    • Multiplication/Division
    • Exponentiation
    • Negation
  • Handful of functions
    • SQRT
    • PI
    • POW
    • COUNT
  • Constant valued variables
Product 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 287 3/13/2024
1.0.0 762 5/9/2022
0.13.0 524 7/30/2021
0.12.0 356 7/28/2021
0.11.0 478 6/23/2021
0.10.1 337 6/21/2021
0.10.0 339 6/3/2021
0.9.0 302 6/1/2021
0.8.0 311 3/29/2021
0.7.0 343 3/18/2021
0.6.0 366 3/16/2021
0.5.1 360 2/9/2021
0.5.0 354 2/9/2021
0.4.0 306 2/8/2021
0.3.0 1,120 2/18/2018
0.2.0 1,014 2/11/2018
0.1.0 1,086 1/31/2018