Pip.Services Logo <br/> Tokenizers, parsers and expression calculators in Dart

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
  • Mustache - Mustache templating engine
  • Tokenizers - lexical analyzers to break incoming character streams into tokens
  • Variants - dynamic objects that can hold any values and operators for them

Quick links:


Add this to your package's pubspec.yaml file:

  pip_services3_expressions: version

Now you can install package from the command line:

pub get

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

import 'package:pip_services3_expressions/src/calculator/calculator.dart';
import 'package:pip_services3_expressions/src/calculator/variables/variables.dart';
import 'package:pip_services3_expressions/src/variants/variants.dart';

var calculator = ExpressionCalculator();

calculator.expression = 'A + b / (5 - Max(-123, 1)*2)';

var vars = VariableCollection();
vars.add(Variable('A', Variant('1')));
vars.add(Variable('B', Variant(3)));

var result = await calculator.evaluateWithVariables(vars);
print('The result of the expression is ' +
    result.asString); // The result of the expression is 11

This is an example to process mustache templates.

import 'package:pip_services3_expressions/src/mustache/mustache.dart';

var mustache = MustacheTemplate();
mustache.template =
    'Hello, {{{NAME}}}{{#ESCLAMATION}}!{{/ESCLAMATION}}{{#unless ESCLAMATION}}.{{/unless}}';
var result =
    mustache.evaluateWithVariables({'NAME': 'Mike', 'ESCLAMATION': true});
print("The result of template evaluation is '" + result.toString() + "'");

For development you shall install the following prerequisites:

  • Dart SDK 2
  • Visual Studio Code or another IDE of your choice
  • Docker

Install dependencies:

pub get

Run automated tests:

pub run test

Generate API documentation:


Before committing changes run dockerized build and test as:



The library is created and maintained by Sergey Seroukhov and Danil Prisiazhnyi.

The documentation is written by Egor Nuzhnykh, Alexey Dvoykin, Mark Makarychev, Levichev Dmitry.