Open dselman opened 2 years ago
https://github.com/mozilla/mozjexl https://github.com/LeanyLabs/formula-engine http://mvel.documentnode.com https://github.com/NeilFraser/JS-Interpreter https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API https://github.com/ipld/ipld/issues/75 https://github.com/WebAssembly/component-model/blob/main/design/high-level/UseCases.md
Feature Request 🛍️
Implement an expression language that uses Concerto types as its type system, and Concerto JSON instances at runtime.
Use Case
We need a safe language to use within Cicero templates, based on the Concerto type system. The language should include a library of basic mathematical, string and date/time functions.
Inspiration: https://gist.githubusercontent.com/fkereki/1830c5ca8680d08b3e38cc4a994d7af2/raw/1fbcc60ef9589c86a4f9457247823508ccb0c68a/gistfile1.txt
Possible Solution
Add a new package
concerto-expression-parser
that includes a DSL implemented using peg.js. The parser AST will then be validated against the type definitions present in aModelManager
.For example, given the model:
The following expression is valid:
While the following expressions are invalid:
Add a second new package
concerto-expression-eval
that evaluates a parser AST against a set of named input objects, producing an output scalar.Context
Migrate Cicero templates away from inline Ergo.
Detailed Description
Target Excel macro type of user. Detect invalid expressions prior to evaluation. Start small and grow the function library progressively over time. Ensure safe evaluation within the web browser, Docker container, JS environments. E.g. no use of JS
eval
.