Last updated:
0 purchases
pip services3 expressions
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:
API Reference
Change Log
Get Help
Contribute
Use #
Add this to your package's pubspec.yaml file:
dependencies:
pip_services3_expressions: version
copied to clipboard
Now you can install package from the command line:
pub get
copied to clipboard
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
...
copied to clipboard
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() + "'");
copied to clipboard
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
copied to clipboard
Run automated tests:
pub run test
copied to clipboard
Generate API documentation:
./docgen.ps1
copied to clipboard
Before committing changes run dockerized build and test as:
./build.ps1
./test.ps1
./clear.ps1
copied to clipboard
Contacts #
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.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.