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
@@ -95,46 +95,89 @@
Classes
</h3>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.FanucSystemControlVariableSyntax.html">FanucSystemControlVariableSyntax</a></dt>
<dd><p>Consumes Fanuc-style system-control variable assignments
(<code>#3000-#3999</code>) — alarm trigger (<code>#3000</code>), millisecond and
hour clocks (<code>#3001</code> / <code>#3002</code>), single-block / feed-hold
bypass flags (<code>#3003</code> / <code>#3004</code>), pause-with-message
(<code>#3006</code>), mirror-image flags (<code>#3007</code>), date / time
(<code>#3011</code> / <code>#3012</code>), tool-life data (<code>#3030</code> /
<code>#3032</code>), etc.</p>
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.CallStackUtil.html">CallStackUtil</a></dt>
<dd><p>Push / pop helpers for the per-block <a class="xref" href="Hi.NcParsers.Keywords.CallStack.html">CallStack</a> section.
Both produce a fresh deep-cloned <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonobject">JsonObject</a> ready to
stamp onto an inlined piece (push site) or onto an M99 return block
(pop site); the caller is responsible for deep-cloning again if it
distributes the same stamp across multiple pieces of an L-repetition.</p>
<p>
Every id in this range is a controller-side state variable — its
authoritative value lives on the real hardware (RTC, alarm bus,
override switches, …) and an NC write at most triggers a side effect
(clock reset, alarm raise, message-pause prompt). Offline simulation
has none of that machinery, so this syntax does <b>not</b> emulate the
effect. Instead it:
Pairs with <a class="xref" href="Hi.NcParsers.PostLogicSyntaxs.ModalCarrySyntax.html">ModalCarrySyntax</a> at the
Logic stage: explicit push / pop writes seed the section at frame
boundaries, ModalCarry copies it forward to every block in between
so each block is self-contained for cache-dump readers and downstream
consumers (notably M99 <code>P{seq}</code> reading the top frame's
<a class="xref" href="Hi.NcParsers.Keywords.CallFrame.html#Hi_NcParsers_Keywords_CallFrame_CallerFilePath">CallerFilePath</a>).
</p>
<ol><li>records the literal write on the block JSON under
<code>Vars.SystemControl</code> (round-trip and cache-dump visibility);</li><li>emits a <code>FanucSystemControl--Unsupported</code>
<a class="xref" href="Hi.NcParsers.NcDiagnosticProgress.html#Hi_NcParsers_NcDiagnosticProgress_UnsupportedMessage_Hi_NcParsers_Sentence_System_String_System_String_System_Object_">UnsupportedMessage(Sentence, string, string, object)</a>
so the user knows the assignment was recognised but its controller-side
effect is not simulated. Message-severity (not Warning) because these
writes are safe no-ops offline — every consumed assignment would emit
a Warning per block, which would be noisy without signalling anything
the user must act on;</li><li>removes the entry from <code>Parsing.Assignments</code> so it does not
re-surface as a generic <code>Parsing--Unconsumed</code> diagnostic.</li></ol>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.LabelScanUtil.html">LabelScanUtil</a></dt>
<dd><p>Shared &ldquo;re-segment a file and skip pieces until a label matches&rdquo;
scan, used by both
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucGotoSyntax.html">FanucGotoSyntax</a> (unconditional GOTO redirect)
and <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramReturnSyntax.html">SubProgramReturnSyntax</a> (<code>M99 P{seq}</code> jump
into the caller file). Reads the file via
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ReadLines_System_Int32_System_String_System_String_">ReadLines(int, string, string)</a>, segments through the
provided <a class="xref" href="Hi.NcParsers.Segmenters.ISegmenter.html">ISegmenter</a>, runs the
<code class="paramref">probeSyntaxes</code> on each candidate block to
extract <code>IndexNote.Number</code>, and returns the slice from the
first matching block to EOF.</p>
<p>
The dictionary carries forward block-by-block (same dict-merge pattern
as <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a>) so a downstream consumer
can read the most recent recorded value via <code>SyntaxPiece</code> linkage.
Returns <code>null</code> when no block matches — the caller's
responsibility to surface the appropriate diagnostic. The probes
are idempotent because the downstream Parsing bundle re-runs the
same syntaxes on the yielded pieces with no-op effect (the regex
patterns no longer match once the N-prefix is consumed and the
parenthesised comment stripped).
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.html">MacroFileResolver</a></dt>
<dd><p>Shared subprogram-/macro-file resolver for Fanuc-style <code>O&lt;n&gt;</code>
lookups consumed by <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a> (M98 / M198)
and <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroCallSyntax.html">FanucMacroCallSyntax</a> (G65). Single helper so the three
path forms — file name, project-relative path, absolute path — are
produced together at one site and each caller gets exactly the form
it should consume:</p>
<ul><li><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ResolvedFile_FileName">FileName</a> — bare <code>O####.NC</code> form
the resolver matched. Stored in JSON sections (<code>FanucMacroCall</code>,
<code>SubProgramCall</code>) as the structural NC-language identifier;
independent of which folder the dependency happened to be pointing
at, so the JSON stays portable across environments.</li><li><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ResolvedFile_RelPath">RelPath</a> — relative path against the
project base directory (e.g. <code>"NC/O1234.NC"</code>). Used as the
<a class="xref" href="Hi.Common.FileLines.IndexedFileLine.html">IndexedFileLine</a> label so diagnostics on inlined blocks
align with the relative form already used for the main file label.</li><li><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ResolvedFile_AbsPath">AbsPath</a> — absolute path. Used only
at the <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ReadLines_System_Int32_System_String_System_String_">ReadLines(int, string, string)</a> call site for actual disk I/O; never
persisted, never returned to JSON. Lives inside the resolver's stack
frame and the segmenter's enumeration.</li></ul>
<p>
Only literal numeric RHS values are consumed; non-literal RHS
(e.g. <code>#3002 = #500</code>) is left in <code>Parsing.Assignments</code> for
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VariableEvaluatorSyntax.html">VariableEvaluatorSyntax</a> to resolve, mirroring the
retained / volatile reading syntaxes.
Filename lookup order (first match wins) mirrors real Fanuc fallback:
<code>O{P:D4}.NC</code>, <code>O{P}.NC</code>, <code>O{P:D4}</code>, <code>O{P}</code>,
<code>{P:D4}.NC</code>, <code>{P}.NC</code>. Case-insensitive match is delegated
to the host filesystem (Windows is, Linux is not).
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroInlineUtil.html">MacroInlineUtil</a></dt>
<dd><p>Shared inline mechanism for Fanuc Custom Macro B body expansion —
used by both <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroCallSyntax.html">FanucMacroCallSyntax</a> (one-shot) and
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucModalMacroSyntax.html">FanucModalMacroSyntax</a>'s expansion phase (modal trigger). Both
callers do the same three things on every produced
<a class="xref" href="Hi.NcParsers.Syntaxs.SyntaxPiece.html">SyntaxPiece</a>: stamp a <a class="xref" href="Hi.NcParsers.Keywords.FanucMacroCall.html">FanucMacroCall</a>
clone, stamp a fresh <a class="xref" href="Hi.NcParsers.Keywords.MacroFrame.html">MacroFrame</a> id, and stamp
argument bindings into <code>Vars.Local</code>. Centralising lets the two
call sites stay in lock-step — frame allocation, file-index
allocation, and the inline-piece JSON shape are guaranteed
identical.</p>
<p>
Fanuc-family only — Siemens uses named system variables
(<code>$AC_TIME</code>, <code>$A_DAY</code>, …) and Heidenhain uses
<code>FN18: SYSREAD</code>; neither flows through <code>Parsing.Assignments.#nnn</code>.
Frame ids share the same <a class="xref" href="Hi.NcParsers.Dependencys.SystemWired.FileIndexCounterDependency.html">FileIndexCounterDependency</a>
counter as file indices — both just need within-session uniqueness
and the counter is rewound on session start in lock-step with the
pipeline. The main NC file is allocated index 0 first, so all
inline frame ids land at &gt; 0 and never collide with main.
</p>
</dd>
</dl>
@@ -204,38 +247,53 @@ repetitions if instances were shared.
</p>
<p>
Not yet supported: <code>M99 P{seq}</code> early return inside a
subprogram, partial-program calls (<code>M98 P{seq}{prog}</code> split
encoding), and arg binding (G65 macro is a separate syntax).
subprogram and partial-program calls (<code>M98 P{seq}{prog}</code> split
encoding). Custom Macro B argument-binding calls (<code>G65</code> /
<code>G66</code> / <code>G67</code>) live in <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucMacroCallSyntax.html">FanucMacroCallSyntax</a> and
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucModalMacroSyntax.html">FanucModalMacroSyntax</a> — those handle the
argument-letter-to-<code>#1..#26</code> binding and the macro-call frame
isolation that M98 deliberately does not provide.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramReturnSyntax.html">SubProgramReturnSyntax</a></dt>
<dd><p>Consumes Fanuc-style <code>M99</code> subprogram-return blocks.</p>
<dd><p>Consumes Fanuc-style <code>M99</code> subprogram-return blocks and pops
one <a class="xref" href="Hi.NcParsers.Keywords.CallStack.html">CallStack</a> frame. Plain <code>M99</code> relies on the
natural pipeline tail — the inlined body's last block is followed
in <code>layers[0]</code> by the caller's next block, so the &ldquo;return&rdquo;
happens implicitly; this syntax only consumes the M99 trigger (so
<a class="xref" href="Hi.NcParsers.InspectionSyntaxs.UnconsumedCheckSyntax.html">UnconsumedCheckSyntax</a> doesn't warn),
stamps a <a class="xref" href="Hi.NcParsers.Keywords.SubProgramReturn.html">SubProgramReturn</a> diagnostic section, and
writes the popped <a class="xref" href="Hi.NcParsers.Keywords.CallStack.html">CallStack</a> for downstream blocks to
carry.</p>
<p>
In the inline model used by <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a>, a
plain <code>M99</code> at the end of a subprogram is implicit: the
inlined blocks are followed in <code>layers[0]</code> by the caller's
next block, so the natural pipeline traversal already does the
"return". This syntax therefore only consumes the M99 flag (so
<a class="xref" href="Hi.NcParsers.InspectionSyntaxs.UnconsumedCheckSyntax.html">UnconsumedCheckSyntax</a> doesn't warn)
and records a <a class="xref" href="Hi.NcParsers.Keywords.SubProgramReturn.html">SubProgramReturn</a> section for cache-dump
visibility.
<code>M99 P{seq}</code> additionally redirects control flow to the
caller's <code>N{seq}</code> block via
<a class="xref" href="Hi.Common.Collections.LazyLinkedList-1.html#Hi_Common_Collections_LazyLinkedList_1_ReplaceSource_System_Collections_Generic_IEnumerable__0__">ReplaceSource(IEnumerable&lt;T&gt;)</a>. The caller's file is
resolved from the popped frame's
<a class="xref" href="Hi.NcParsers.Keywords.CallFrame.html#Hi_NcParsers_Keywords_CallFrame_CallerFilePath">CallerFilePath</a>; the scan uses the same
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.LabelScanUtil.html#Hi_NcParsers_EvaluationSyntaxs_LabelScanUtil_SegmentAndSkipUntilLabel_Hi_NcParsers_Segmenters_ISegmenter_System_String_System_String_System_Int32_System_Int32_System_Int32_System_Collections_Generic_List_Hi_NcParsers_Syntaxs_ISituNcSyntax__Hi_NcParsers_NcDiagnosticProgress_">SegmentAndSkipUntilLabel(ISegmenter, string, string, int, int, int, List&lt;ISituNcSyntax&gt;, NcDiagnosticProgress)</a> helper as
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucGotoSyntax.html">FanucGotoSyntax</a>, with hardcoded Fanuc-default
probes (<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.CommentSyntaxs.QuoteCommentSyntax.html">QuoteCommentSyntax</a> + <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.HeadIndexSyntax.html">HeadIndexSyntax</a>
with symbol <code>"N"</code>) because the M99 P semantic itself is
Fanuc-family-only and Mazak / Syntec follow the same conventions.
The iteration is counted against
<a class="xref" href="Hi.NcParsers.Dependencys.Fanuc.FanucGotoIterationDependency.html">FanucGotoIterationDependency</a>, sharing the same
runaway-loop guard as GOTO — keyed on the same
<code>(FileName, TargetN)</code> bucket so a tight
<code>M98 → M99 P → M98 …</code> loop trips the same threshold.
</p>
<p>
<code>M99 P{seq}</code> (return to caller's <code>N{seq}</code> sequence
number) is captured in <a class="xref" href="Hi.NcParsers.Keywords.SubProgramReturn.html#Hi_NcParsers_Keywords_SubProgramReturn_P">P</a> but not yet
honoured — the subprogram tail still proceeds straight into the
caller's next block. Implementing the jump requires a forward scan
of the post-host caller blocks for a matching <code>N{seq}</code> head
index, then dropping the intervening blocks; deferred until the
caller-side walk semantics are designed.
</p>
<p>
Pipeline placement: anywhere after Parsing has populated
<code>Parsing.M99</code>. Conventionally placed alongside
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a> at the head of the Evaluation
bundle so call/return live next to each other.
Pipeline placement: same Evaluation bundle slot it always occupied,
right after <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.SubProgramCallSyntax.html">SubProgramCallSyntax</a> at the head. Needs
<a class="xref" href="Hi.NcParsers.Dependencys.Fanuc.FanucGotoIterationDependency.html">FanucGotoIterationDependency</a>,
<a class="xref" href="Hi.NcParsers.Dependencys.SystemWired.ProjectFolderDependency.html">ProjectFolderDependency</a>,
<a class="xref" href="Hi.NcParsers.Dependencys.SystemWired.SegmenterDependency.html">SegmenterDependency</a>,
<a class="xref" href="Hi.NcParsers.Dependencys.SystemWired.SyntaxPieceLayerDependency.html">SyntaxPieceLayerDependency</a>,
<a class="xref" href="Hi.NcParsers.Dependencys.SystemWired.FileIndexCounterDependency.html">FileIndexCounterDependency</a> on the dep list when
<code>M99 P{seq}</code> is to fire; without them the plain-M99 path still
works and the P-jump emits a configuration warning.
</p>
<p>
Detection is on the <code>Parsing.M99</code> sub-object written by
@@ -256,7 +314,7 @@ appears — but does <b>not</b> write to any specific store. Routing
&ldquo;where the resolved literal lands&rdquo; stays in the brand-specific
reader syntaxes (<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a>,
<a class="xref" href="Hi.NcParsers.Dependencys.Fanuc.RetainedCommonVariableTable.html">RetainedCommonVariableTable</a>'s reader,
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.FanucSystemControlVariableSyntax.html">FanucSystemControlVariableSyntax</a>, …) which run
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.Fanuc.FanucSystemControlVariableSyntax.html">FanucSystemControlVariableSyntax</a>, …) which run
<i>after</i> this syntax on the same block.</p>
<p>
Two passes per block:
@@ -275,7 +333,7 @@ from <code>Parsing.&lt;tag&gt;</code> (axis tags, canned-cycle sub-objects)
is parsed; on a successful evaluation the string is replaced with a
numeric <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonvalue">JsonValue</a>. Failures silently leave the original
string and rely on downstream
<a class="xref" href="Hi.NcParsers.SoftNcUtil.html#Hi_NcParsers_SoftNcUtil_GetParsedDouble_System_Text_Json_Nodes_JsonObject_System_String_Hi_NcParsers_Sentence_Hi_NcParsers_NcDiagnosticProgress_">GetParsedDouble(JsonObject, string, Sentence, NcDiagnosticProgress)</a> at consumer sites to surface
<a class="xref" href="Hi.NcParsers.SoftNcUtil.html#Hi_NcParsers_SoftNcUtil_GetParsedDouble_System_Text_Json_Nodes_JsonObject_System_String_Hi_NcParsers_ISentenceCarrier_Hi_NcParsers_NcDiagnosticProgress_">GetParsedDouble(JsonObject, string, ISentenceCarrier, NcDiagnosticProgress)</a> at consumer sites to surface
<code>VariableExpression--Unevaluated</code> only if the tag is actually read.
</li></ol>
<p>
@@ -339,6 +397,18 @@ The two syntaxes are decoupled — the evaluator's lookup tracebacks via
<code>SyntaxPiece</code> linkage so it does not depend on having run before
or after this syntax.
</p>
</dd>
</dl>
<h3 id="structs">
Structs
</h3>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html">MacroFileResolver.ResolvedFile</a></dt>
<dd><p>Tri-form resolution result. <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ResolvedFile_FileName">FileName</a> is the bare
matched name; <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ResolvedFile_RelPath">RelPath</a> is that name joined with the
folder portion of the dependency (relative when the folder is
configured relative, absolute fallback when it isn't);
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.MacroFileResolver.ResolvedFile.html#Hi_NcParsers_EvaluationSyntaxs_MacroFileResolver_ResolvedFile_AbsPath">AbsPath</a> is the fully-resolved I/O target.</p>
</dd>
</dl>