Add formula engine: data-driven expression evaluator (Core)
CI / build-test (push) Successful in 1m19s
CI / build-test (push) Successful in 1m19s
Keystone for the gene system. A Formula compiles a string from a def (lexer -> recursive-descent parser -> tree of Func<IFormulaContext,float>) once, then evaluates allocation-free against a variable context. Supports + - * / %, comparisons, && || !, ternary, the constants pi/tau/e, and functions abs sign floor ceil round sqrt exp log sin cos tan min max pow clamp lerp step. Deterministic and side-effect-free so gene-effect formulas stay pure. Covered by FormulaTests (parsing, precedence, functions, logic/ternary, variables, errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2ac074004a
commit
10898b08a0
@@ -0,0 +1,12 @@
|
||||
namespace MrGameEng.Formulas;
|
||||
|
||||
/// <summary>
|
||||
/// Thrown when a <see cref="Formula"/> cannot be lexed or parsed, or when a compiled formula
|
||||
/// references a variable the context cannot resolve at evaluation time.
|
||||
/// </summary>
|
||||
public sealed class FormulaException : Exception
|
||||
{
|
||||
/// <summary>Creates the exception with a human-readable <paramref name="message"/>.</summary>
|
||||
public FormulaException(string message)
|
||||
: base(message) { }
|
||||
}
|
||||
Reference in New Issue
Block a user