299 lines
16 KiB
HTML
299 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Namespace Hi.NcParsers.EvaluationSyntaxs.Evaluation | HiAPI-C# 2025 </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="Namespace Hi.NcParsers.EvaluationSyntaxs.Evaluation | HiAPI-C# 2025 ">
|
|
|
|
|
|
<link rel="icon" href="../img/HiAPI.favicon.ico">
|
|
<link rel="stylesheet" href="../public/docfx.min.css">
|
|
<link rel="stylesheet" href="../public/main.css">
|
|
<meta name="docfx:navrel" content="../toc.html">
|
|
<meta name="docfx:tocrel" content="toc.html">
|
|
|
|
<meta name="docfx:rel" content="../">
|
|
|
|
|
|
|
|
<meta name="loc:inThisArticle" content="In this article">
|
|
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<meta name="loc:tocFilter" content="Filter by title">
|
|
<meta name="loc:nextArticle" content="Next">
|
|
<meta name="loc:prevArticle" content="Previous">
|
|
<meta name="loc:themeLight" content="Light">
|
|
<meta name="loc:themeDark" content="Dark">
|
|
<meta name="loc:themeAuto" content="Auto">
|
|
<meta name="loc:changeTheme" content="Change theme">
|
|
<meta name="loc:copy" content="Copy">
|
|
<meta name="loc:downloadPdf" content="Download PDF">
|
|
|
|
<script type="module" src="./../public/docfx.min.js"></script>
|
|
|
|
<script>
|
|
const theme = localStorage.getItem('theme') || 'auto'
|
|
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
|
<header class="bg-body border-bottom">
|
|
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
|
<div class="container-xxl flex-nowrap">
|
|
<a class="navbar-brand" href="../index.html">
|
|
<img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
|
|
|
|
</a>
|
|
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
|
<i class="bi bi-three-dots"></i>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navpanel">
|
|
<div id="navbar">
|
|
<form class="search" role="search" id="search">
|
|
<i class="bi bi-search"></i>
|
|
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
|
|
<main class="container-xxl">
|
|
<div class="toc-offcanvas">
|
|
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
|
<div class="offcanvas-header">
|
|
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
|
</div>
|
|
<div class="offcanvas-body">
|
|
<nav class="toc" id="toc"></nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<div class="actionbar">
|
|
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
|
<i class="bi bi-list"></i>
|
|
</button>
|
|
|
|
<nav id="breadcrumb"></nav>
|
|
</div>
|
|
|
|
<article data-uid="Hi.NcParsers.EvaluationSyntaxs.Evaluation">
|
|
|
|
<h1 id="Hi_NcParsers_EvaluationSyntaxs_Evaluation" data-uid="Hi.NcParsers.EvaluationSyntaxs.Evaluation" class="text-break">Namespace Hi.NcParsers.EvaluationSyntaxs.Evaluation</h1>
|
|
<div class="markdown level0 summary"></div>
|
|
<div class="markdown level0 conceptual"></div>
|
|
<div class="markdown level0 remarks"></div>
|
|
|
|
<h3 id="classes">
|
|
Classes
|
|
</h3>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.LocalVariableLookup.html">LocalVariableLookup</a></dt>
|
|
<dd><p>Reads Fanuc-style local macro variables (<code>#1-#33</code>) from
|
|
<code>Vars.Local</code> on the current <a class="xref" href="Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a> JSON,
|
|
walking <a class="xref" href="Hi.Common.Collections.LazyLinkedListNode-1.html#Hi_Common_Collections_LazyLinkedListNode_1_Previous">Previous</a> until the entry
|
|
is found. Self-gates the id range so the evaluator's
|
|
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VariableEvaluatorSyntax.html#Hi_NcParsers_EvaluationSyntaxs_VariableEvaluatorSyntax_RuntimeVariableLookups">RuntimeVariableLookups</a> chain can
|
|
fall through to the next lookup for out-of-range keys.</p>
|
|
<p>
|
|
Stateless and dependency-free — instances are interchangeable.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcBinaryExpr.html">NcBinaryExpr</a></dt>
|
|
<dd><p>Binary arithmetic on two operands (<code>+ - * /</code> or <code>MOD</code>).</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpr.html">NcExpr</a></dt>
|
|
<dd><p>AST root for a Fanuc Custom Macro B value expression. Concrete leaves
|
|
and combinators sit alongside <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionParser.html">NcExpressionParser</a>; walking
|
|
is the job of <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html">NcExpressionEvaluator</a>.</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html">NcExpressionEvaluator</a></dt>
|
|
<dd><p>Walks an <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpr.html">NcExpr</a> AST and produces an <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.EvalResult.html">EvalResult</a>.
|
|
Resolves <code>#nnn</code> via an <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.IVariableLookup.html">IVariableLookup</a>; built-in function
|
|
names are matched case-insensitively against a fixed table.</p>
|
|
<p>
|
|
Phase-1 supports: <code>SIN COS TAN ASIN ACOS ATAN SQRT ABS ROUND FIX FUP LN
|
|
EXP POW</code>. Trigonometric arguments and results are in degrees, matching
|
|
Fanuc Custom Macro B convention. Unknown function names surface as
|
|
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_NcExpressionEvaluator_UnsupportedFunctionCode">UnsupportedFunctionCode</a>; arity mismatches as
|
|
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_NcExpressionEvaluator_ArgumentMismatchCode">ArgumentMismatchCode</a>; division / MOD by zero and domain
|
|
errors (e.g. <code>SQRT[-1]</code>) as <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_NcExpressionEvaluator_MathErrorCode">MathErrorCode</a>; vacant
|
|
operands as <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_NcExpressionEvaluator_VacantErrorCode">VacantErrorCode</a>.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionParser.html">NcExpressionParser</a></dt>
|
|
<dd><p>Recursive-descent parser for Fanuc Custom Macro B value expressions.
|
|
Pure: takes a string, produces an <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpr.html">NcExpr</a> AST. Performs no
|
|
variable lookup and no evaluation.</p>
|
|
<p>Grammar (highest precedence last):</p>
|
|
<pre><code class="lang-csharp">expr := term (('+' | '-') term)*
|
|
term := factor (('*' | '/' | 'MOD') factor)*
|
|
factor := ('+' | '-')? primary
|
|
primary := number
|
|
| '#' integer
|
|
| '#' '[' expr ']'
|
|
| '[' expr ']'
|
|
| ident '[' arglist ']' ('/' '[' expr ']')?
|
|
arglist := expr (',' expr)*</code></pre>
|
|
<p>
|
|
Function names are case-insensitive (<code>SIN</code> = <code>sin</code>); whitespace
|
|
is skipped between tokens. The <code>'/' '[' expr ']'</code> tail captures the
|
|
dual-bracket form Fanuc uses for <code>ATAN[a]/[b]</code>; non-ATAN callers that
|
|
happen to use it produce a function with an extra arg, which the evaluator
|
|
rejects with an arity error.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcFunctionExpr.html">NcFunctionExpr</a></dt>
|
|
<dd><p>Built-in function call like <code>SIN[x]</code>, <code>SQRT[x]</code>, <code>ATAN[a]/[b]</code>.</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcIndirectVariableExpr.html">NcIndirectVariableExpr</a></dt>
|
|
<dd><p>Indirect variable reference <code>#[expr]</code>. The inner expression is
|
|
evaluated and truncated toward zero to obtain an integer; the lookup key
|
|
is then <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcIndirectVariableExpr.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_NcIndirectVariableExpr_Prefix">Prefix</a> concatenated with that integer
|
|
(e.g. <code>Prefix="#"</code>, computed <code>124</code> → <code>"#124"</code>).</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcLiteralExpr.html">NcLiteralExpr</a></dt>
|
|
<dd><p>Numeric literal (e.g. <code>1.5</code>, <code>15.</code>, <code>.5</code>, <code>1e-3</code>).</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcUnaryExpr.html">NcUnaryExpr</a></dt>
|
|
<dd><p>Unary <code>+</code> or <code>-</code> applied to an operand.</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcVariableExpr.html">NcVariableExpr</a></dt>
|
|
<dd><p>Direct variable reference; <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcVariableExpr.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_NcVariableExpr_Key">Key</a> is the raw source token
|
|
(e.g. <code>"#124"</code>) passed verbatim to <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.IVariableLookup.html#Hi_NcParsers_EvaluationSyntaxs_Evaluation_IVariableLookup_Get_System_String_">Get(string)</a>.</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.VolatileVariableLookup.html">VolatileVariableLookup</a></dt>
|
|
<dd><p>Reads Fanuc-style non-retained common variables (<code>#100-#499</code>)
|
|
from <code>Vars.Volatile</code> on the current <a class="xref" href="Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a>
|
|
JSON, walking <a class="xref" href="Hi.Common.Collections.LazyLinkedListNode-1.html#Hi_Common_Collections_LazyLinkedListNode_1_Previous">Previous</a> until the
|
|
entry is found. Self-gates the id range so the evaluator's
|
|
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VariableEvaluatorSyntax.html#Hi_NcParsers_EvaluationSyntaxs_VariableEvaluatorSyntax_RuntimeVariableLookups">RuntimeVariableLookups</a> chain can
|
|
fall through to the next lookup for out-of-range keys.</p>
|
|
<p>
|
|
Stateless and dependency-free — instances are interchangeable.
|
|
Reads use the same dict-merge carry that
|
|
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a> writes; the two stay
|
|
decoupled (read side here; write side in the reader).
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<h3 id="structs">
|
|
Structs
|
|
</h3>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.EvalResult.html">EvalResult</a></dt>
|
|
<dd><p>Outcome of evaluating an <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpr.html">NcExpr</a>. Either a successful
|
|
numeric value, or a failure with an error code matching the diagnostic
|
|
catalogue used by reading / evaluator syntaxes.</p>
|
|
</dd>
|
|
</dl>
|
|
<h3 id="interfaces">
|
|
Interfaces
|
|
</h3>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.IRuntimeVariableLookup.html">IRuntimeVariableLookup</a></dt>
|
|
<dd><p>Stateless variable lookup that needs per-block runtime context — the
|
|
current <a class="xref" href="Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a> node (for <a class="xref" href="Hi.Common.Collections.LazyLinkedListNode-1.html#Hi_Common_Collections_LazyLinkedListNode_1_Previous">Previous</a>
|
|
traceback into runtime-state sections like <code>MachineCoordinateState</code>
|
|
/ <code>ProgramXyz</code>) and the dependency list (so the lookup can read
|
|
from sibling dependencies without holding a static reference).</p>
|
|
<p>
|
|
Distinguished from <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.IVariableLookup.html">IVariableLookup</a>: that one is for
|
|
long-lived dependencies that already hold their own data (parameter
|
|
tables, tool-offset wrappers, retained-variable tables) and need no
|
|
block context. <code>IRuntimeVariableLookup</code> is for context-sensitive
|
|
resolutions configured declaratively on
|
|
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VariableEvaluatorSyntax.html#Hi_NcParsers_EvaluationSyntaxs_VariableEvaluatorSyntax_RuntimeVariableLookups">RuntimeVariableLookups</a>.
|
|
</p>
|
|
<p>
|
|
Implementations should be brand-specific (e.g. Fanuc <code>#5001-#5043</code>
|
|
position reads) and return <code>null</code> for keys outside their range so
|
|
the evaluator's chain can fall through to the next lookup.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.IVariableLookup.html">IVariableLookup</a></dt>
|
|
<dd><p>Resolves a Custom Macro B variable reference to its current numeric value,
|
|
or <code>null</code> for vacant (Fanuc <code><vacant></code>) and out-of-scope alike.</p>
|
|
<p>
|
|
The key is the raw source token — Fanuc <code>"#124"</code>, Heidenhain
|
|
<code>"Q1"</code>, Siemens <code>"R1"</code> — so the interface itself is brand-agnostic.
|
|
Implementations are typically narrow (one per id range / per brand prefix)
|
|
and parse the prefix locally; chain them at the call site by trying each
|
|
in priority order until one returns a non-<code>null</code> value.
|
|
</p>
|
|
<p>
|
|
A returned <code>null</code> is treated by <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcExpressionEvaluator.html">NcExpressionEvaluator</a>
|
|
as vacant and surfaces as a <code>Variable--Vacant</code> failure when the
|
|
value is consumed in arithmetic context.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<h3 id="enums">
|
|
Enums
|
|
</h3>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcBinaryOp.html">NcBinaryOp</a></dt>
|
|
<dd><p>Binary operators allowed in Fanuc Custom Macro B value expressions.</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="jumplist">
|
|
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.NcUnaryOp.html">NcUnaryOp</a></dt>
|
|
<dd><p>Unary operators allowed in Fanuc Custom Macro B value expressions.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
</article>
|
|
|
|
<div class="contribution d-print-none">
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="affix">
|
|
<nav id="affix"></nav>
|
|
</div>
|
|
</main>
|
|
|
|
<div class="container-xxl search-results" id="search-results"></div>
|
|
|
|
<footer class="border-top text-secondary">
|
|
<div class="container-xxl">
|
|
<div class="flex-fill">
|
|
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|