NFun
NFun copied to clipboard
Expressions Evaluator for .NET
Hello! ```c# Dictionary varMap = new() { ["sec"] = () => DateTime.Now.Second }; var calc = Funny.WithFunction("vars", (string name) => varMap[name]()).BuildForCalcConstant(); var result = calc.Calc("1 + vars('sec')"); Console.WriteLine(result); ``` These...
Under most cases when working with UInt16 and Int16 types seem to have a bug saying it didn't receive what it expected even though the exception actually says it did...
``` out = [[1],true] ``` expected: out: any actual: Runtime error. Unable to cast from Real[] to Bool - [x] workaround: deny such casts for a while - [x] allow...
``` y = if (true) false else 12 ``` Expected: ``` y:any == false ``` Actual: ``` Error: TicIncompatibleAncestorSyntaxNodeException : Incompatible ancestor 2:[U8..Re]Re!=>3:Bo ```
``` var user = new User(age, name, cars); Funny.Serializer.Serialize(user); /* output * { * age = 25 * name = 'vasa' * cars = [ * {size = 1} *...
``` class Car{ public int Power {get;set;} public string Name {get;set;} public int Year {get;set;} } var result = Funny.Calc("{ power = 120 }");// Name and Year are not initalized...
allow to write it like that: ``` {a}.{b}.{c}.{d} ``` where a,b,c,d is type of byte
As char is arithmetic type - it can be used in such an expressions: ``` word = [/'a'../'c'] #'abc' ips = [127.0.0.1.. 127.0.0.5] # [127.0.0.1, 127.0.0.2, 127.0.0.3, 127.0.0.4, 127.0.0.5] range(a,b)...
``` [TestCase("'avatar'.reverse() > reverse('avatar') ", false)] [TestCase("('avatar'.reverse()) > reverse('avatar') ", false)] [TestCase("'avatar'.reverse() < 'avatar'", false)] public void ConstantEquation(string expr, bool expected) => expr.AssertReturns("out", expected); ``` Causes ``` System.InvalidCastException : Unable...
Assume '' as multiline node (not in syntax, but for example of how it works under the hood) for example: ``` a = let: d = b**2 -4a*c { #value...