Expression
Parsing and evaluation of expressions with named inputs.
Parses an expression with Parse and evaluates it with Execute using positional Variant inputs. This is an expression language rather than a C# interpreter. Check the Parse Error first, then HasExecuteFailed after Execute and the result type. Nil may be valid. GetErrorText can retain an earlier error after a successful Execute. constCallsOnly restricts object method calls rather than isolating arbitrary untrusted code.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ExpressionConstructor
public Expression();Methods5
ExecuteVariant
public Variant Execute(Reckfell.Collections.Array inputs = null, ReckfellObject baseInstance = null, bool showError = true, bool constCallsOnly = false);Evaluates a successfully parsed expression. Check HasExecuteFailed afterward; old error text does not identify a current failure. Supply new inputs to reevaluate without parsing again.
| Name | Type | Default |
|---|---|---|
inputs | Reckfell.Collections.Array | null |
baseInstance | ReckfellObject | null |
showError | bool | true |
constCallsOnly | bool | false |
inputsValues in the inputNames order from Parse. Accessing a missing input causes execution failure. null supplies an empty array.
baseInstanceObject for implicit method/property access. null supplies no such object; it does not restrict every built-in expression function.
showErrorWhen true, ordinary evaluation failures are also printed by the engine. false allows handling through HasExecuteFailed/GetErrorText; it does not make evaluation succeed.
constCallsOnlyRestricts Variant object method calls to constant calls. It does not disable all built-ins or guarantee isolation, no side effects or resource limits.
VariantThe Variant result. Nil is a valid value and does not alone indicate failure. Do not use the result as a successful calculation when HasExecuteFailed is true.
GetErrorTextstring
public string GetErrorText();Returns diagnostic text. Parse clears it, but a successful Execute need not clear an earlier failure message. Check the current operation status first.
stringParse or execution error text; it may be empty or stale after a successful Execute.
HasExecuteFailedbool
public bool HasExecuteFailed();Check immediately after Execute. Detect Parse failure through its returned Error rather than this method.
booltrue when the last Execute failed; false after successful execution, including a Nil result.
Parse2 overloads
public Error Parse(string expression, ReadOnlySpan<string> inputNames);Replaces the previous parsed expression and clears error text. Input names determine the order of values in a later Execute. Do not Execute after a parse failure.
| Name | Type | Default |
|---|---|---|
expression | string | — |
inputNames | ReadOnlySpan<string> | — |
expressionExpression-language source text. Its literals, operators and supported calls are not arbitrary C# syntax.
inputNamesNames of input values in the order of the later Execute array. An empty span declares no named inputs.
ErrorError.Ok on successful parsing; Error.InvalidParameter on a parse error. Read GetErrorText for details.
public Error Parse(string expression, string[] inputNames = null);Replaces the previous parsed expression and clears error text. Input names determine the order of values in a later Execute. Do not Execute after a parse failure.
| Name | Type | Default |
|---|---|---|
expression | string | — |
inputNames | string[] | null |
expressionExpression-language source text. Its literals, operators and supported calls are not arbitrary C# syntax.
inputNamesNames of input values in the order of the later Execute array. null means an empty list.
ErrorError.Ok on successful parsing; Error.InvalidParameter on a parse error. Read GetErrorText for details.