rename XFactory.Regs to XFactory.Generators.

This commit is contained in:
2026-05-23 21:23:06 +08:00
parent 8b285cc863
commit 058003f395
155 changed files with 16416 additions and 1261 deletions
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Class NcExpressionParser | HiAPI-C# 2025 ">
<meta name="description" content="Recursive-descent parser for Fanuc Custom Macro B value expressions. Pure: takes a string, produces an AST. Performs no variable lookup and no evaluation. Grammar (highest precedence last): expr := term ((&#39;+&#39; | &#39;-&#39;) term)* term := factor ((&#39;*&#39; | &#39;/&#39; | &#39;MOD&#39;) factor)* factor := (&#39;+&#39; | &#39;-&#39;)? primary primary := number | &#39;#&#39; integer | &#39;#&#39; &#39;[&#39; expr &#39;]&#39; | &#39;[&#39; expr &#39;]&#39; | ident &#39;[&#39; arglist &#39;]&#39; (&#39;/&#39; &#39;[&#39; expr &#39;]&#39;)? arglist := expr (&#39;,&#39; expr)* Function names are case-insensitive (SIN = sin); whitespace is skipped between tokens. The &#39;/&#39; &#39;[&#39; expr &#39;]&#39; tail captures the dual-bracket form Fanuc uses for ATAN[a]/[b]; non-ATAN callers that happen to use it produce a function with an extra arg, which the evaluator rejects with an arity error.">
<meta name="description" content="Recursive-descent parser for Fanuc Custom Macro B value expressions. Pure: takes a string, produces an AST. Performs no variable lookup and no evaluation. Grammar (lowest precedence at top): expr := or-expr or-expr := and-expr ((&#39;OR&#39; | &#39;XOR&#39;) and-expr)* and-expr := cmp-expr (&#39;AND&#39; cmp-expr)* cmp-expr := add-expr ((&#39;EQ&#39; | &#39;NE&#39; | &#39;GT&#39; | &#39;GE&#39; | &#39;LT&#39; | &#39;LE&#39;) add-expr)* add-expr := term ((&#39;+&#39; | &#39;-&#39;) term)* term := factor ((&#39;*&#39; | &#39;/&#39; | &#39;MOD&#39;) factor)* factor := (&#39;+&#39; | &#39;-&#39;)? primary primary := number | &#39;#&#39; integer | &#39;#&#39; &#39;[&#39; expr &#39;]&#39; | &#39;[&#39; expr &#39;]&#39; | ident &#39;[&#39; arglist &#39;]&#39; (&#39;/&#39; &#39;[&#39; expr &#39;]&#39;)? arglist := expr (&#39;,&#39; expr)* Function names and keyword operators (MOD, EQ NE GT GE LT LE, AND OR XOR) are case-insensitive (SIN = sin, EQ = eq); each keyword requires a non-identifier character on its right boundary so EQ1 is not the EQ operator followed by 1. Whitespace is skipped between tokens. The &#39;/&#39; &#39;[&#39; expr &#39;]&#39; tail captures the dual-bracket form Fanuc uses for ATAN[a]/[b]; non-ATAN callers that happen to use it produce a function with an extra arg, which the evaluator rejects with an arity error. Operator precedence intentionally puts boolean / logical layers below arithmetic so #1 + 1 GT 0 parses as (#1 + 1) GT 0 and #1 GT 0 AND #2 LT 10 parses as (#1 GT 0) AND (#2 LT 10), matching the Fanuc Custom Macro B spec for IF [..] GOTO / IF [..] THEN / WHILE [..] DO conditions.">
<link rel="icon" href="../img/HiAPI.favicon.ico">
<link rel="stylesheet" href="../public/docfx.min.css">
<link rel="stylesheet" href="../public/main.css">
@@ -100,22 +100,37 @@ Class NcExpressionParser
<div class="markdown summary"><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>Grammar (lowest precedence at top):</p>
<pre><code class="lang-csharp">expr := or-expr
or-expr := and-expr (('OR' | 'XOR') and-expr)*
and-expr := cmp-expr ('AND' cmp-expr)*
cmp-expr := add-expr (('EQ' | 'NE' | 'GT' | 'GE' | 'LT' | 'LE') add-expr)*
add-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.
Function names and keyword operators (<code>MOD</code>, <code>EQ NE GT GE LT LE</code>,
<code>AND OR XOR</code>) are case-insensitive (<code>SIN</code> = <code>sin</code>,
<code>EQ</code> = <code>eq</code>); each keyword requires a non-identifier character
on its right boundary so <code>EQ1</code> is not the <code>EQ</code> operator
followed by <code>1</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>
<p>
Operator precedence intentionally puts boolean / logical layers below
arithmetic so <code>#1 + 1 GT 0</code> parses as <code>(#1 + 1) GT 0</code> and
<code>#1 GT 0 AND #2 LT 10</code> parses as <code>(#1 GT 0) AND (#2 LT 10)</code>,
matching the Fanuc Custom Macro B spec for <code>IF [..] GOTO</code> /
<code>IF [..] THEN</code> / <code>WHILE [..] DO</code> conditions.
</p>
</div>
<div class="markdown conceptual"></div>