Today I’ll start a series of posts about building your own scripting language + business rule engine which can be used in .Net applications.
Background
Sometimes a custom scripting language can come in handy when we want the end user to be able to configure our system, for example:
- formulas, business rules
example: a discount for products/services, some sort of calculations - conditions, validation rules
example: max invoice price
Requirements
- It should be simple so that power users can use it – maybe similar to excel formulas?
- It should be callable from .net.
- It should be extensible.
- It should allow minor grammar changes.
- It should be fast and simple to use for the developer.
- It should be safe – user cannot execute arbitary code.
Maybe something like this:
FormulaCompiler compiler = new FormulaCompiler(); var f = compiler.Compile<bool>("Inner.Value=2 OR Value=4"); Assert( true, f() );
It the next post I’ll present the overall design of my language which is called Formula.