This commit is contained in:
2026-09-09 17:35:23 +08:00
parent 2a98ae7556
commit 161af68fe3
1271 changed files with 58251 additions and 98639 deletions
@@ -182,6 +182,56 @@ Note that the <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFla
</dd></dl>
<h2 id="Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_examples">Examples</h2>
<p>The cases below run the Fanuc-family
<a class="xref" href="Hi.NcParsers.Syntaxs.FanucSyntaxUtil.html#Hi_NcParsers_Syntaxs_FanucSyntaxUtil_G54p1Syntax">G54p1Syntax</a> instance
(<code>CodePrefixes = [&ldquo;G54.1&rdquo;]</code>, <code>IntParamPrefixes = [&ldquo;P&rdquo;]</code>,
<code>ParamGatedAliases = {&ldquo;G54&rdquo; → &ldquo;G54.1&rdquo;}</code>, <code>TerminateWords =
[&ldquo;G&rdquo;, &ldquo;M&rdquo;]</code>). The consumed span is cut out of the text as-is, so the
residue keeps the spaces that surrounded the code and its P word — the
spaced and the glued spellings differ only there.</p>
<p>
Canonical spelling with a space (<code>G54.1 P48</code>) — captured as an
integer P under <code>Parsing.G54.1</code>, the rest of the block left for
the later syntaxes:
</p>
#BeforeBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G0 G90 G54.1 P48 X0. Y0." }</code></pre>
#AfterBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G0 G90 X0. Y0.", "Parsing": { "G54.1": { "P": 48 } } }</code></pre>
Canonical spelling glued (<code>G54.1P48</code>, glued axis words too):
#BeforeBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G00 G90 G54.1P48 X0.Y0." }</code></pre>
#AfterBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G00 G90 X0.Y0.", "Parsing": { "G54.1": { "P": 48 } } }</code></pre>
The alias spelling with a space — a customer post's block, verbatim —
lands under the canonical key exactly like the first case:
#BeforeBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G0 G90 G54 P48 X0. Y0." }</code></pre>
#AfterBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G0 G90 X0. Y0.", "Parsing": { "G54.1": { "P": 48 } } }</code></pre>
The alias spelling glued (<code>G54P48</code>), the same post's other habit,
in the same file:
#BeforeBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G00 G90 G54P48 X0.Y0." }</code></pre>
#AfterBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G00 G90 X0.Y0.", "Parsing": { "G54.1": { "P": 48 } } }</code></pre>
A bare <code>G54</code> (no P word anywhere in its scope) is not this flag:
the alias grabs nothing, consumes nothing, and the block is left for
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.NumberedFlagSyntax.html">NumberedFlagSyntax</a> to read the plain G54 flag — no
<code>Parsing</code> object is created:
#BeforeBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G00 G90 G54 X-24.048 Y-52.446" }</code></pre>
#AfterBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "G00 G90 G54 X-24.048 Y-52.446" }</code></pre>
A lower-case program: the key is the configured spelling
(<code>"G54.1"</code>) and the parameter tag is upper-cased, while the
untouched residue keeps its case:
#BeforeBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "g0 g90 g54 p4 x0. y0." }</code></pre>
#AfterBuild:
<pre><code class="lang-csharp">{ "UnparsedText": "g0 g90 x0. y0.", "Parsing": { "G54.1": { "P": 4 } } }</code></pre>
<h2 id="Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_remarks">Remarks</h2>
<div class="markdown level0 remarks"><p>Parameters can be stored as typed values via <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_FloatParamPrefixes">FloatParamPrefixes</a>
@@ -189,6 +239,33 @@ and <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.ht
<ul><li><a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamPrefixes">ParamPrefixes</a> — stored as string (text, for variables like #1, Q2)</li><li><a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_FloatParamPrefixes">FloatParamPrefixes</a> — stored as <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> when parseable, string otherwise</li><li><a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_IntParamPrefixes">IntParamPrefixes</a> — stored as <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> when parseable, string otherwise</li></ul>
Examples:
<ul><li>G54.1P1 → {"G54.1": {"P": "1"}} (text)</li><li>G68.2 X0 I180 → {"G68.2": {"X": 0.0, "I": 180.0}} (float via property initializer)</li><li>G54.1P#1 → {"G54.1": {"P": "#1"}} (Fanuc variable, kept as string)</li><li>G54.1PQ1 → {"G54.1": {"P": "Q1"}} (Heidenhain variable)</li></ul>
<p>
The stored key is the code's configured spelling (the
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_CodePrefixes">CodePrefixes</a> entry that matched, or the canonical code an
alias maps to), not the text as written: the match is case-insensitive,
so a lower-case program (<code>g54.1 p4</code>) still lands under
<code>"G54.1"</code> where the logic syntaxes look it up.
</p>
<p>
A spelling that only means this flag when a parameter follows — Fanuc's
<code>G54 Pn</code> for the additional work coordinate system, where a bare
<code>G54</code> is the ordinary work-offset flag — is declared in
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamGatedAliases">ParamGatedAliases</a> rather than <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_CodePrefixes">CodePrefixes</a>.
An alias hit that grabs no parameter is left in the text untouched for
the later syntaxes; an alias hit with a parameter is stored under its
canonical code, indistinguishable from the canonical spelling.
</p>
<p>
A canonical code that grabs no parameter (a bare <code>G43</code> whose H is
omitted, a bare <code>G41</code> resuming the modal D) is likewise left in
the text and lands in <code>Parsing.Flags</code> through the trailing
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.NumberedFlagSyntax.html">NumberedFlagSyntax</a>. It is never stored as an empty
object: <code>CleanupParsing</code> strips empty objects, and
<a class="xref" href="Hi.NcParsers.EvaluationSyntaxs.VariableEvaluatorSyntax.html">VariableEvaluatorSyntax</a> runs one on
every block, so an empty <code>{"G43": {}}</code> would vanish before the
logic syntax that owns it ran. Consumers therefore look for their code
both as a parameter object and as a flag.
</p>
</div>
@@ -204,8 +281,8 @@ Examples:
</h3>
<div class="markdown level1 summary"><p>Creates a new ParameterizedFlagSyntax instance.
Use property initializers for <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_FloatParamPrefixes">FloatParamPrefixes</a> and
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_IntParamPrefixes">IntParamPrefixes</a> to enable typed parameter storage.</p>
Use property initializers for <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_FloatParamPrefixes">FloatParamPrefixes</a>,
<a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_IntParamPrefixes">IntParamPrefixes</a> and <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamGatedAliases">ParamGatedAliases</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
@@ -250,7 +327,7 @@ Use property initializers for <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.
</h3>
<div class="markdown level1 summary"><p>Loads all prefix lists, variable prefix, and terminator words from XML.</p>
<div class="markdown level1 summary"><p>Loads all prefix lists, aliases, variable prefix, and terminator words from XML.</p>
</div>
<div class="markdown level1 conceptual"></div>
@@ -444,6 +521,46 @@ Set via property initializer for typed G-code parameters.</p>
<a id="Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamGatedAliases_" data-uid="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.ParamGatedAliases*"></a>
<h3 id="Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamGatedAliases" data-uid="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.ParamGatedAliases">
ParamGatedAliases
</h3>
<div class="markdown level1 summary"><p>Alternative spellings that denote one of the <a class="xref" href="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.html#Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_CodePrefixes">CodePrefixes</a>
only when at least one parameter follows: key = the spelling as
written in NC text, value = the canonical code the capture is stored
under. Matched case-insensitively. A hit that grabs no parameter is
left in the text for the later syntaxes — the spelling keeps its own
meaning there (Fanuc's <code>G54 Pn</code> is the additional work coordinate
system, a bare <code>G54</code> the ordinary work-offset flag). Serialized
as <code>&lt;ParamGatedAliases&gt;&lt;Entry Key=&ldquo;G54&rdquo;&gt;G54.1&lt;/Entry&gt;</code>,
omitted when empty.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Dictionary&lt;string, string&gt; ParamGatedAliases { get; set; }</code></pre>
</div>
<h4 class="section">Property Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2">Dictionary</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>&gt;</dt>
<dd></dd>
</dl>
<a id="Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamPrefixes_" data-uid="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.ParamPrefixes*"></a>
<h3 id="Hi_NcParsers_ParsingSyntaxs_ParameterizedFlagSyntax_ParamPrefixes" data-uid="Hi.NcParsers.ParsingSyntaxs.ParameterizedFlagSyntax.ParamPrefixes">