fix SoftNcRunner GM code normalization.

This commit is contained in:
2026-05-16 18:08:13 +08:00
parent e026da61b3
commit 8b285cc863
765 changed files with 18689 additions and 9785 deletions
@@ -648,13 +648,13 @@ triggered program end (M02 / M30, identified by the
Real Fanuc clears non-retained common variables (#100-#499) on program
end + reset; this syntax models that behaviour at the simulator level.
The clear happens on the same block that carried M02/M30 — the next
block's <a class="xref" href="Hi.NcParsers.LogicSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a> carry then sees an
block's <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a> carry then sees an
empty dictionary on the predecessor and starts fresh.
</p>
<p>
Pipeline placement: must run after both <a class="xref" href="Hi.NcParsers.LogicSyntaxs.ProgramEndSyntax.html">ProgramEndSyntax</a>
(which writes the <a class="xref" href="Hi.NcParsers.Keywords.ProgramEnd.html">ProgramEnd</a> section this syntax checks)
and <a class="xref" href="Hi.NcParsers.LogicSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a> (so the carry has
and <a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a> (so the carry has
already happened on this block; this syntax overwrites the result).
</p>
<p>
@@ -790,31 +790,6 @@ Overwrites root <a class="xref" href="Hi.NcParsers.Keywords.IMachineCoordinateSt
and <a class="xref" href="Hi.NcParsers.Keywords.IProgramXyzDef.html#Hi_NcParsers_Keywords_IProgramXyzDef_ProgramXyz">ProgramXyz</a> with reference position
for subsequent block lookback.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.LogicSyntaxs.RetainedCommonVariableReadingSyntax.html">RetainedCommonVariableReadingSyntax</a></dt>
<dd><p>Obtains values for Fanuc-style retained common variables (<code>#500-#999</code>)
by consuming literal numeric assignments from <code>Parsing.Assignments.#nnn</code>
and writing them straight to a registered
<a class="xref" href="Hi.NcParsers.Dependencys.Fanuc.RetainedCommonVariableTable.html">RetainedCommonVariableTable</a>.</p>
<p>
No SyntaxPiece JSON mirror is created — the table is the single source of
truth for retained values, and <a class="xref" href="Hi.NcParsers.LogicSyntaxs.VariableEvaluatorSyntax.html">VariableEvaluatorSyntax</a> reads
from the table directly. The hincproj round-trip preserves writes across
project sessions.
</p>
<p>
Only literal numeric RHS values are consumed by this syntax
(<code>#500 = 1.234</code> ✓; <code>#600 = #500 + 1</code> ✗). Non-literal RHS entries
are left untouched in <code>Parsing.Assignments</code>; <a class="xref" href="Hi.NcParsers.LogicSyntaxs.VariableEvaluatorSyntax.html">VariableEvaluatorSyntax</a>
resolves them and writes the result through the same table. The two
syntaxes are decoupled.
</p>
<p>
If no <a class="xref" href="Hi.NcParsers.Dependencys.Fanuc.RetainedCommonVariableTable.html">RetainedCommonVariableTable</a> is registered on the
runner's <code>NcDependencyList</code>, this syntax is a no-op.
</p>
</dd>
</dl>
<dl class="jumplist">
@@ -901,70 +876,6 @@ are forced to pre-convert the NC program to metric.
<a class="xref" href="Hi.NcParsers.Keywords.Generic.IsoKeywords.html#Hi_NcParsers_Keywords_Generic_IsoKeywords_G21">G21</a> is accepted as a no-op confirmation of
the default.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.LogicSyntaxs.VariableEvaluatorSyntax.html">VariableEvaluatorSyntax</a></dt>
<dd><p>Resolves Custom Macro B variable references and bracket expressions on
a single block by walking the parser-stage residue and replacing each
reference with its evaluated numeric value.</p>
<p>
Two passes per block:
</p>
<ol><li>
<code>Parsing.Assignments.#nnn</code> entries with a non-literal RHS are
evaluated in iteration order. Successful results are written to
<code>Vars.Volatile</code> for <code>#100-#499</code> or to the registered
<code>RetainedCommonVariableTable</code> for <code>#500-#999</code>, and the
entry is removed. Iteration order matters: an earlier RHS may set a
variable that a later RHS reads. Failures (vacant operand, unsupported
function, parse error) emit a <code>VariableExpression--Unevaluated</code>
error and leave the entry in place; out-of-range ids are likewise left
in place.
</li><li>
Every string-typed value reachable from <code>Parsing.&lt;tag&gt;</code>
(axis tags, canned-cycle sub-objects like <code>Parsing.G81</code>,
<code>Parsing.G54.1</code>, etc.) 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
<code>VariableExpression--Unevaluated</code> only if the tag is actually read.
</li></ol>
<p>
Lookup chain (first non-null wins):
</p>
<ol><li>Block-local <code>Vars.Local</code> with <a class="xref" href="Hi.Common.Collections.LazyLinkedListNode-1.html#Hi_Common_Collections_LazyLinkedListNode_1_Previous">Previous</a> traceback (<code>#1-#33</code>).</li><li>Block-local <code>Vars.Volatile</code> with traceback (<code>#100-#499</code>).</li><li>Each <a class="xref" href="Hi.NcParsers.LogicSyntaxs.Evaluation.IVariableLookup.html">IVariableLookup</a> in the runner's <code>NcDependencyList</code>, in registration order (e.g. <code>RetainedCommonVariableTable</code>, <code>FanucParameterTable</code>, <code>FanucToolOffsetTable</code>).</li><li>Each <a class="xref" href="Hi.NcParsers.LogicSyntaxs.Evaluation.IRuntimeVariableLookup.html">IRuntimeVariableLookup</a> in <a class="xref" href="Hi.NcParsers.LogicSyntaxs.VariableEvaluatorSyntax.html#Hi_NcParsers_LogicSyntaxs_VariableEvaluatorSyntax_RuntimeVariableLookups">RuntimeVariableLookups</a>, in list order (e.g. <code>FanucPositionVariableLookup</code>).</li></ol>
<p>
Each lookup is responsible for its own id-range gating — id ranges are
not hard-coded inside this syntax. Adding a new variable surface
(Heidenhain Q parameters, Siemens GUDs, modal G/F/T reads) is additive:
register an <a class="xref" href="Hi.NcParsers.LogicSyntaxs.Evaluation.IVariableLookup.html">IVariableLookup</a> on a dependency or push an
<a class="xref" href="Hi.NcParsers.LogicSyntaxs.Evaluation.IRuntimeVariableLookup.html">IRuntimeVariableLookup</a> onto the per-preset list.
</p>
</dd>
</dl>
<dl class="jumplist">
<dt><a class="xref" href="Hi.NcParsers.LogicSyntaxs.VolatileVariableReadingSyntax.html">VolatileVariableReadingSyntax</a></dt>
<dd><p>Obtains values for Fanuc-style non-retained common variables
(<code>#100-#499</code>). Reads literal numeric assignments from
<code>Parsing.Assignments.#nnn</code>, dict-merges them with the previous block's
volatile state, and writes the resulting per-block dictionary into
<code>Vars.Volatile</code>.</p>
<p>
Lifetime is bounded by <code>MachiningSession</code>: within one session the
dictionary carries forward block-by-block via this syntax; session restart
abandons the SyntaxPiece JSON dataflow and starts fresh. Program-end
(M02/M30) clearing is handled by <a class="xref" href="Hi.NcParsers.LogicSyntaxs.ProgramEndCleanSyntax.html">ProgramEndCleanSyntax</a>.
</p>
<p>
Only literal numeric RHS values are consumed by this syntax
(<code>#124 = 15.</code> ✓; <code>#100 = #1 + 5</code> ✗). Non-literal RHS entries
are left untouched in <code>Parsing.Assignments</code>; <a class="xref" href="Hi.NcParsers.LogicSyntaxs.VariableEvaluatorSyntax.html">VariableEvaluatorSyntax</a>
resolves them and writes the result into the same per-block dictionary.
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>