Table of Contents

Class NcExpressionEvaluator

Namespace
Hi.NcParsers.EvaluationSyntaxs.Evaluation
Assembly
HiMech.dll

Walks an NcExpr AST and produces an EvalResult. Resolves #nnn via an IVariableLookup; built-in function names are matched case-insensitively against a fixed table.

Phase-1 supports: SIN COS TAN ASIN ACOS ATAN SQRT ABS ROUND FIX FUP LN EXP POW. Trigonometric arguments and results are in degrees, matching Fanuc Custom Macro B convention. Unknown function names surface as UnsupportedFunctionCode; arity mismatches as ArgumentMismatchCode; division / MOD by zero and domain errors (e.g. SQRT[-1]) as MathErrorCode; vacant operands as VacantErrorCode.

Numeric domain & type conventions. All values are IEEE 754 double — there is no separate bool / int type at runtime. Comparison ops (EQ NE GT GE LT LE) yield 1.0 (true) or 0.0 (false), using strict double equality / ordering (NaN compares as IEEE specifies — NaN EQ NaN is 0.0). Logical ops (AND OR XOR) truncate each operand to a 64-bit signed integer (Truncate(double) then cast to long) before applying the bitwise operation; non-finite or out-of-range operands surface MathErrorCode rather than silently wrapping. Truthiness at caller-side IF / WHILE gates is value != 0 — any non-zero value (bit, float, comparator result) is true.

public sealed class NcExpressionEvaluator
Inheritance
NcExpressionEvaluator
Inherited Members
Extension Methods

Fields

ArgumentMismatchCode

Diagnostic code for built-in functions called with the wrong number of arguments.

public const string ArgumentMismatchCode = "BuiltinFunction--ArgumentMismatch"

Field Value

string

MathErrorCode

Diagnostic code for division / MOD by zero and domain errors.

public const string MathErrorCode = "Arithmetic--MathError"

Field Value

string

UnsupportedFunctionCode

Diagnostic code for unrecognised built-in function names.

public const string UnsupportedFunctionCode = "BuiltinFunction--Unsupported"

Field Value

string

VacantErrorCode

Diagnostic code emitted when an evaluated #nnn is vacant.

public const string VacantErrorCode = "Variable--Vacant"

Field Value

string

Methods

Evaluate(NcExpr, IVariableLookup)

Evaluates expr against variables.

public EvalResult Evaluate(NcExpr expr, IVariableLookup variables)

Parameters

expr NcExpr
variables IVariableLookup

Returns

EvalResult