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
@@ -114,6 +114,36 @@ comments (and any embedded CsScript) still take effect.</li></ul>
Not a comment: a comment is static metadata, block skip is a runtime
toggle that can change per machine/operator setting.
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.CallFrame.html">CallFrame</a></dt>
<dd><p>One entry in <a class="xref" href="Hi.NcParsers.Keywords.CallStack.html#Hi_NcParsers_Keywords_CallStack_Frames">Frames</a>. Holds the caller-side
information consumers need to &ldquo;unwind&rdquo; or &ldquo;look back&rdquo; — currently
only the relative file path of the caller, used by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramReturnSyntax.html">SubProgramReturnSyntax</a> on
<code>M99 P{seq}</code> to locate the caller's <code>N{seq}</code> block.</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.CallStack.html">CallStack</a></dt>
<dd><p>JSON-section data shape representing the active call-frame stack on
a block — pushed by call-and-inline syntaxes
(<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a> for M98/M198,
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroCallSyntax.html">FanucMacroCallSyntax</a> for G65, and
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucModalMacroSyntax.html">FanucModalMacroSyntax</a>'s expansion
phase for G66 implicit triggers) and popped by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramReturnSyntax.html">SubProgramReturnSyntax</a> on M99. Every
block between push and pop carries the section forward via
<a class="xref" href="Hi.NcParsers.PostLogicSyntaxs.ModalCarrySyntax.html">ModalCarrySyntax</a>; the caller's blocks
before push and after pop carry the surrounding stack state
(typically empty when running from the main file).</p>
<p>
The section is wrapped in a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonobject">JsonObject</a> rather than
exposed as a bare <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonarray">JsonArray</a> so it fits ModalCarry's
"deep-clone JsonObject" carry pattern — the array of frames lives
inside <a class="xref" href="Hi.NcParsers.Keywords.CallStack.html#Hi_NcParsers_Keywords_CallStack_Frames">Frames</a>.
</p>
</dd>
</dl>
<dl class="jumplist">
@@ -164,6 +194,97 @@ Heidenhain: CYCL DEF 247 (Datum Preset) / CYCL DEF 7 (Datum Shift).
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.Dwell.html">Dwell</a></dt>
<dd><p>Section key holder + concrete implementation for <a class="xref" href="Hi.NcParsers.Keywords.IDwellDef.html">IDwellDef</a>.</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.FanucGoto.html">FanucGoto</a></dt>
<dd><p>Fanuc Custom Macro B GOTO record. Stamped on the host block by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucGotoSyntax.html">FanucGotoSyntax</a> after the control-flow
decision has been made; produced earlier by
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.Fanuc.FanucGotoParsingSyntax.html">FanucGotoParsingSyntax</a> as a parsing-stage
sub-section (<code>Parsing.FanucGoto</code>) carrying the raw captured fields.</p>
<p>
Two source forms map to the same shape:
<ul><li><code>GOTO &lt;n&gt;</code> — unconditional jump. <a class="xref" href="Hi.NcParsers.Keywords.FanucGoto.html#Hi_NcParsers_Keywords_FanucGoto_Condition">Condition</a> is null.</li><li><code>IF [&lt;bool-expr&gt;] GOTO &lt;n&gt;</code> — conditional jump.
<a class="xref" href="Hi.NcParsers.Keywords.FanucGoto.html#Hi_NcParsers_Keywords_FanucGoto_Condition">Condition</a> holds the expression text from inside the
brackets.</li></ul>
<p>
At parsing time <a class="xref" href="Hi.NcParsers.Keywords.FanucGoto.html#Hi_NcParsers_Keywords_FanucGoto_N">N</a> is a raw token from the source — it may
be a literal (<code>"100"</code>), a variable reference (<code>"#1"</code>), or a
bracketed expression (<code>"#[#2+5]"</code>). VariableEvaluatorSyntax
substitutes a resolved literal back into the same field in the
Evaluation bundle; <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucGotoSyntax.html">FanucGotoSyntax</a> then
<code>int.TryParse</code>s the final string to produce an int target.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.FanucIfThen.html">FanucIfThen</a></dt>
<dd><p>Fanuc Custom Macro B <code>IF [&lt;cond&gt;] THEN &lt;body&gt;</code>
single-block conditional record. Stamped on the host block by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucIfThenSyntax.html">FanucIfThenSyntax</a> after the gate
decision; produced earlier by
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.Fanuc.FanucIfThenParsingSyntax.html">FanucIfThenParsingSyntax</a> as a parsing-stage
sub-section (<code>Parsing.FanucIfThen</code>) carrying the raw captured fields
plus an internal <code>PendingAssignments</code> sub-object harvested from the
body text.</p>
<p>
Spec: <code>IF [bool-expr] THEN &lt;stmt&gt;</code> executes <code>&lt;stmt&gt;</code>
only when the condition is truthy. Unlike <a class="xref" href="Hi.NcParsers.Keywords.FanucGoto.html">FanucGoto</a>'s
conditional form there is no jump — the body affects the current block
only, no source splice, no label scan, no iteration watchdog. The most
common body shape is a single Custom Macro B assignment
(<code>#nnn = &lt;expr&gt;</code>); multiple assignments in one body are also
accepted and lifted together.
</p>
<p>
<a class="xref" href="Hi.NcParsers.Keywords.FanucIfThen.html#Hi_NcParsers_Keywords_FanucIfThen_Condition">Condition</a> is held as a string at parsing time so
VariableEvaluatorSyntax's pass-2 tree walk can substitute
it to a numeric <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonvalue">JsonValue</a> in place;
the FanucIfThenSyntax tail then reads the resolved node polymorphically
via the same <code>ReadCondition</code> shape used by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucGotoSyntax.html">FanucGotoSyntax</a>.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.FanucMacroCall.html">FanucMacroCall</a></dt>
<dd><p>One-shot custom-macro-call record written by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroCallSyntax.html">FanucMacroCallSyntax</a>. Lives on both the
<code>G65</code> host block (the caller) and every inlined block of the
macro body — so a cache-dump reader can land on any block inside the
macro and immediately see &ldquo;this block belongs to a G65 call of
File with these argument bindings&rdquo; without back-walking
to find the host.</p>
<p>
Each inlined block additionally carries the resolved
<code>Vars.Local</code> <code>#1-#26</code> bindings derived from <a class="xref" href="Hi.NcParsers.Keywords.FanucMacroCall.html#Hi_NcParsers_Keywords_FanucMacroCall_Args">Args</a>
(see <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroArgumentMap.html">FanucMacroArgumentMap</a>), so
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Evaluation.LocalVariableLookup.html">LocalVariableLookup</a>
resolves macro args in a single-block lookup. Frame isolation is
structural: caller blocks never have <code>Vars.Local</code> written, so
after the macro body ends, the next caller block reads <code>null</code>
for any <code>#1-#26</code> without any explicit frame marker.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.FanucModalMacro.html">FanucModalMacro</a></dt>
<dd><p>Modal-macro-call record left by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucModalMacroSyntax.html">FanucModalMacroSyntax</a>. Carries Fanuc
<code>G66</code> setup state forward block-to-block until cancelled by
<code>G67</code>. The section is also written on the <code>G67</code> block itself
(with <a class="xref" href="Hi.NcParsers.Keywords.FanucModalMacro.html#Hi_NcParsers_Keywords_FanucModalMacro_Term">Term</a> = <code>&ldquo;G67&rdquo;</code>) so cache dumps show the cancel
edge; subsequent blocks then carry no section at all.</p>
<p>
Per-block expansion of the modal call into an actual macro inline at
every positioning move is not yet implemented — a
<code>FanucModalMacro--NotExpanded</code> warning is emitted on the setup
block to flag the simulation gap. The setup state itself is captured
faithfully so external tooling can detect "this block sits inside a
G66 modal" via the carried section.
</p>
</dd>
</dl>
<dl class="jumplist">
@@ -215,6 +336,32 @@ do not share this key, because their data shapes are richer.
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.MachineCoordinateState.html">MachineCoordinateState</a></dt>
<dd><p>Section key holder for <a class="xref" href="Hi.NcParsers.Keywords.IMachineCoordinateStateDef.html">IMachineCoordinateStateDef</a>.</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.MacroFrame.html">MacroFrame</a></dt>
<dd><p>Top-level integer marker stamped onto a SyntaxPiece's JSON
to identify which call frame the block belongs to. Brand-agnostic by
design — written by <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroCallSyntax.html">FanucMacroCallSyntax</a>
today, reusable by any future call-inlining syntax (Fanuc <code>G66</code>
modal expansion, Heidenhain <code>LBL CALL</code>, …) that needs
local-variable isolation across call boundaries.</p>
<p>
Semantics: the value is an opaque id; only equality matters. Two
blocks with the same <a class="xref" href="Hi.NcParsers.Keywords.MacroFrame.html">MacroFrame</a> id share a call frame
(locals visible across them via single-step carry); two blocks with
different ids do not. The id <code>0</code> is reserved for the main
program frame and is returned by <a class="xref" href="Hi.NcParsers.Keywords.MacroFrame.html#Hi_NcParsers_Keywords_MacroFrame_Get_System_Text_Json_Nodes_JsonObject_">Get(JsonObject)</a> when the field is
absent — so a plain caller block needs no stamp and yet compares
distinct from any inlined frame.
</p>
<p>
Stored as a top-level JSON int (not an object section) so it stays
lightweight on every inlined block. Decoupled from
<a class="xref" href="Hi.NcParsers.Keywords.FanucMacroCall.html">FanucMacroCall</a>: that section is a diagnostic record of
the call (what file, what args), while <code>MacroFrame</code> is the
purely functional marker the local-variable I/O syntaxes consult.
</p>
</dd>
</dl>
<dl class="jumplist">
@@ -274,11 +421,19 @@ do not share this key, because their data shapes are richer.
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.SubProgramCall.html">SubProgramCall</a></dt>
<dd><p>Subprogram call record left on the M98 / M198 host block by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a> after the subprogram
file has been inlined into the source layer. The call itself emits no
motion act; this section is bookkeeping so cache dumps and diagnostic
readers can see &quot;this block triggered an inline of file <code>File</code>&quot;.</p>
<dd><p>Subprogram call record left by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a> on the M98 /
M198 host block and on every inlined body block. The call itself
emits no motion act; this section is bookkeeping so cache dumps and
diagnostic readers can see &quot;this block triggered (or sits inside)
an inline of program <code>P</code>&quot;.</p>
<p>
<code>M98</code> and <code>M198</code> share the exact same section shape. The
difference between them is purely environmental — which folder the
resolver looks in (<code>SubProgramFolderConfig.InternalFolder</code> vs
<code>ExternalFolder</code>) — and that lives on the dependency, not in
this JSON record.
</p>
</dd>
</dl>
<dl class="jumplist">
@@ -286,8 +441,7 @@ readers can see &quot;this block triggered an inline of file <code>File</code>&q
<dd><p>Subprogram return record left on the M99 host block by
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramReturnSyntax.html">SubProgramReturnSyntax</a>. Return blocks
produce no motion acts; this section makes the consumed M99 visible
in cache dumps and reserves a slot for future <code>M99 P{seq}</code>
(return-to-sequence-number) support.</p>
in cache dumps and surfaces the <code>M99 P{seq}</code> jump decision.</p>
</dd>
</dl>
<dl class="jumplist">
@@ -459,11 +613,24 @@ as NaN sentinels.
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.Keywords.IMotionEventDef.html">IMotionEventDef</a></dt>
<dd><p>One-shot motion event — present only on blocks that actually issue a
motion command. Used by motion semantics (<a class="xref" href="Hi.NcParsers.Semantics.McLinearMotionSemantic.html">McLinearMotionSemantic</a>,
<dd><p>One-shot motion event — present on every block whose source <em>programmed</em>
a motion command, regardless of whether the resulting displacement is non-zero.
A redundant <code>G01 X10</code> on a block already at X10 still gets a
<a class="xref" href="Hi.NcParsers.Keywords.MotionEvent.html">MotionEvent</a>; the motion semantics
(<a class="xref" href="Hi.NcParsers.Semantics.McLinearMotionSemantic.html">McLinearMotionSemantic</a>,
<a class="xref" href="Hi.NcParsers.Semantics.McArcMotionSemantic.html">McArcMotionSemantic</a>, <a class="xref" href="Hi.NcParsers.Semantics.ClLinearMotionSemantic.html">ClLinearMotionSemantic</a>)
as the trigger to emit motion <a class="xref" href="Hi.Numerical.Acts.IAct.html">IAct</a>. NOT carried
forward across blocks. Property names are used as JSON keys via <code>nameof</code>.</p>
then early-return on <code>distance &lt;= 0</code> and emit no
<a class="xref" href="Hi.Numerical.Acts.IAct.html">IAct</a>. NOT carried forward across blocks.</p>
<p>
Reason for the "programmed, not displaced" definition: Fanuc G66 modal
macro fires once per <em>programmed</em> motion command (per Fanuc spec —
no distance gate), so <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucModalMacroSyntax.html">FanucModalMacroSyntax</a>.Expansion uses
<a class="xref" href="Hi.NcParsers.Keywords.MotionEvent.html">MotionEvent</a> presence as its trigger. Suppressing the section
on zero-distance moves would silently change G66 behaviour. The modal
sibling <a class="xref" href="Hi.NcParsers.Keywords.MotionState.html">MotionState</a> separately latches the Group-01 mode for
readers that only need to know "what G-code is active".
</p>
Property names are used as JSON keys via <code>nameof</code>.
</dd>
</dl>
<dl class="jumplist">