Skip to content

Tokenizers, parsers and expression calculators for Pip.Services in .NET

License

Notifications You must be signed in to change notification settings

pip-services3-dotnet/pip-services3-expressions-dotnet

Repository files navigation

Pip.Services Logo
Tokenizers, parsers and expression calculators for .NET

This module is a part of the Pip.Services polyglot microservices toolkit. It provides syntax and lexical analyzers and expression calculator optimized for repeated calculations.

The module contains the following packages:

  • Calculator - Expression calculator
  • CSV - CSV tokenizer
  • IO - input/output utility classes to support lexical analysis
  • Tokenizers - lexical analyzers to break incoming character streams into tokens
  • Variants - dynamic objects that can hold any values and operators for them

Quick links:

Use

Install the dotnet package as

dotnet add package PipServices3.Expressions

The example below shows how to use expression calculator to dynamically calculate user-defined expressions.

using PipServices3.Commons.Config;
using PipServices3.Commons.Refer;
using PipServices3.Commons.Run;
using PipServices3.Expressions.Calculator;
using PipServices3.Expressions.Calculator.Variables;
using PipServices3.Expressions.Variants;

ExpressionCalculator calculator = new ExpressionCalculator();

calculator.Expression = "A + b / (3 - Max(-123, 1)*2)";

VariableCollection vars = new VariableCollection();
vars.Add(new Variable("A", new Variant(1)));
vars.Add(new Variable("B", new Variant(3)));

Variant result = calculator.EvaluateUsingVariablesAsync(vars).Result;
Console.WriteLine("The result of the expression is " + result.ToString());
...

Develop

For development you shall install the following prerequisites:

  • Core .NET SDK 3.1+
  • Visual Studio Code or another IDE of your choice
  • Docker

Restore dependencies:

dotnet restore src/src.csproj

Compile the code:

dotnet build src/src.csproj

Run automated tests:

dotnet restore test/test.csproj
dotnet test test/test.csproj

Generate API documentation:

./docgen.ps1

Before committing changes run dockerized build and test as:

./build.ps1
./test.ps1
./clear.ps1

Contacts

The .NET version of Pip.Services is created and maintained by:

  • Sergey Seroukhov

About

Tokenizers, parsers and expression calculators for Pip.Services in .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published