Table of Contents

Namespace Hi.NcParsers.LogicSyntaxs

Classes

BackBoringSyntax

G87 back boring cycle. Supports modal repetition. Cuts upward from Z to R — used to bore the back side of a workpiece.

Cycle sequence:

  1. Oriented spindle stop (OSS) at current position
  2. Rapid (shifted) to init position, then down to bottom Z — tool enters pre-drilled hole without contacting bore wall
  3. Shift back to hole center at bottom
  4. Spindle start (CW)
  5. Feed upward from Z to R-point (back boring cut)
  6. Oriented spindle stop at R
  7. Tool shift, rapid retract (shifted) to final Z
  8. Shift back to center, spindle restart

Q specifies the lateral shift distance (mm). Shift direction defaults to +X (OSS angle 0°).

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax before this syntax runs.

BoringCycleSyntax

G85/G86/G89 boring cycles.

Cycle sequence:

  1. Rapid to init position (target XY, previous Z)
  2. Rapid from init to R-point
  3. Feed from R-point to bottom Z
  4. [G86 only] Spindle stop at bottom
  5. [G89 only] Dwell P seconds at bottom
  6. Retract: G85/G89 → feed retract, G86 → rapid retract
  7. [G86 only] Spindle restart (CW) after retract

G85: feed to Z, feed retract — smooth bore finish. G86: feed to Z, spindle stop (implicit), rapid retract. G89: feed to Z, dwell P, feed retract — like G85 with bottom dwell.

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.

CannedCycleResolveSyntax

Resolves the canned-cycle Group-09 state for the current block and writes the result to the CannedCycle section.

  • Active cycle (direct G81..G89 or modal repeat): merges Parsing overrides with previous-cycle stored params, applies G91 incremental-to-absolute conversion and missing-axis fallback, writes CannedCycle with Term, ReturnMode, and Params. The resolved cycle sub-section is left in Parsing under the cycle code for downstream cycle syntaxes (DrillingCycleSyntax, etc.) to read.
  • Explicit cancel (G80 flag present on a non-cycle block): consumes the G80 flag and writes CannedCycle = { Term: "G80" }, acting as a hard sentinel for Hi.NcParsers.LogicSyntaxs.CannedCycleSyntaxUtil modal lookback.
  • No Group-09 activity: leaves the block untouched.

Must be placed after PositioningModeSyntax and before the individual cycle syntaxes in the chain.

CircularMotionSyntax

Writes McArc motion for circular commands (ISO G02/G03). Detects motion mode from Flags, reads I/J/K center offsets or R radius from Parsing, computes arc center in program coordinates, and writes IMotionDef + IArcMotionDef data.

G02/G03 mode is modal (Group 01) — persists via backward lookback. Arc parameters (I/J/K/R) are per-block and must be present in every arc block.

Must be placed before LinearMotionSyntax in the syntax chain. Both share the Group 01 Hi.Motion slot; whichever writes first claims it.

CoolantSyntax

Consumes M07 (mist ON), M08 (flood ON), and M09 (coolant OFF) from Flags and writes the ICoolantDef section with both IsOn (convenience flag) and Mode (abstract mode name: Flood / Mist / Off). Modal — persists via backward lookback.

CoordinateOffsetUtil

Shared utilities for all coordinate offset syntaxes (ISO, Siemens, Heidenhain). Handles section IO, backward lookback, and EndPointProgramToMcTransform composition.

DrillingCycleSyntax

G81/G82 drilling cycle (rapid retract). Supports modal repetition. G82 covers G81 — the only difference is an optional dwell (P) at the bottom.

Cycle sequence:

  1. Rapid to init position (target XY, previous Z)
  2. Rapid from init to R-point
  3. Feed from R-point to bottom Z
  4. [G82 only] Dwell P seconds at bottom
  5. Rapid from bottom to final (G98 → init Z, G99 → R)

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.

FeedrateSyntax

Consumes F (feedrate) from Parsing and G94/G95 mode from Flags. Both are modal — persist across blocks via backward node lookback. Writes resolved state to a IFeedrateDef section.

FineBoringSyntax

G76 fine boring cycle. Supports modal repetition.

Cycle sequence:

  1. Rapid to init position (target XY, previous Z)
  2. Rapid from init to R-point
  3. Feed from R-point to bottom Z
  4. Oriented spindle stop (OSS)
  5. Tool shift by Q in +X direction (clear bore wall)
  6. Rapid retract (shifted) to final Z
  7. Tool shift back to center
  8. Spindle restart (CW)

Q specifies the lateral shift distance (mm) to avoid dragging the tool across the finished bore surface during retract. Shift direction defaults to +X (OSS angle 0°).

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax before this syntax runs.

G43p4RtcpSyntax

Handles G43.4 RTCP (Rotary Tool Center Point) activation. Writes IToolHeightCompensationDef section (including the IsRotaryDynamic flag) and the ToolHeightCompensationSource entry in EndPointProgramToMcTransform — a tool-normal · offset_mm translation at the block endpoint ABC.

The RTCP kinematic rotary part (Pn→MC rigid transform) is orthogonal to this syntax and is written by PivotTransformationSyntax on every block, because rotary state remains in effect beyond the RTCP modal (e.g. a non-RTCP G01 after G49 still inherits the last ABC from the program).

The "rotary dynamic" distinction is captured by IsRotaryDynamic alone, and read by LinearMotionSyntax to pick ClLinear vs McLinear.

G43.4 is used by Fanuc, Mazak, Syntec, and Okuma. Siemens (TRAORI) and Heidenhain (M128) are handled by separate syntaxes. Must be placed after ToolHeightOffsetSyntax (to override the ToolHeightCompensation entry when RTCP is active) and before PivotTransformationSyntax (which runs last in the chain).

G53p1RotaryPositionSyntax

G53.1 — non-modal, one-shot rotary axis positioning. Positions the rotary axes (A/B/C) to align the physical tool axis with the active tilted work plane defined by G68.2. XYZ position is unchanged; only rotary axes move via rapid traverse.

Requires IsoG68p2TiltSyntax (or equivalent) to have written the tilt transform. Uses IMachineKinematics to solve for the target A/B/C via inverse kinematics.

Must be placed after IsoG68p2TiltSyntax (needs tilt data) and before ProgramXyzSyntax in the syntax chain. Writes A/B/C into MachineCoordinate. Motion is handled by LinearMotionSyntax via modal G00/G01.

HighSpeedPeckCycleSyntax

G73 high-speed peck drilling cycle (chip breaking). Supports modal repetition. Drills in increments of depth Q, partially retracting by PeckRetractionDistance_mm between strokes (instead of fully back to R like PeckDrillingCycleSyntax).

Cycle sequence:

  1. Rapid to init position (target XY, previous Z)
  2. Rapid from init to R-point
  3. For each stroke: feed Q deeper, rapid retract by d
  4. If remainder exists: feed to bottom Z, rapid retract by d
  5. Rapid to final (G98 → init Z, G99 → R)

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.

IncrementalResolveSyntax

Resolves G91 incremental axis values to absolute in-place within Parsing and its sub-sections. Reads PositioningMode written by PositioningModeSyntax.

WorkingPathList specifies which JSON paths contain axis values that need incremental-to-absolute conversion. Default: [["Parsing"], ["Parsing", "G28"]]. All matching paths are converted.

Canned cycle paths (Parsing.G81, G82, G83, …) are intentionally excluded — their Z/R incremental semantics differ from normal axes (R is relative to init level, Z is relative to R-point). Resolution is handled by ResolveCycleCoordinates(JsonObject, Vec3d, double?, double?, double, double) inside each cycle syntax class, which runs before this syntax.

Uses AxisNames to determine which tags are motion axes. Traces backward nodes for last known ProgramXyz to resolve incremental values. After this syntax, all axis values in the working paths are absolute — ProgramXyzSyntax can consume them without incremental logic.

IsoCoordinateOffsetSyntax

ISO/Fanuc/Mazak/Okuma/Syntec: resolves G54–G59.9 work coordinate offset. Reads G54/G55/.../G59.9 from Flags, looks up offset Vec3d from IsoCoordinateTable dependency, composes into EndPointProgramToMcTransform. Modal — active coordinate persists via backward lookback. Default coordinate ID is set by StaticInitializer.

IsoG68RotationSyntax

ISO/Fanuc: resolves G68 (2D coordinate rotation) and G69 (cancel). Computes a rotation Mat4d around the active plane normal and composes it into EndPointProgramToMcTransform.

No IMachineKinematics dependency needed — G68 is pure geometric rotation.

Managed commands: G68, G69 (idempotent with IsoG68p2TiltSyntax).

IsoG68p2TiltSyntax

ISO/Fanuc: resolves G68.2 (tilted work plane) and G69 (cancel). Computes a tilt Mat4d from I/J/K euler angles (Fanuc ZXZ convention) and composes it into EndPointProgramToMcTransform.

Managed commands: G68.2, G69 (idempotent with IsoG68RotationSyntax). Siemens equivalent: CYCLE800 (separate syntax). Heidenhain equivalent: PLANE SPATIAL (separate syntax).

IsoLocalCoordinateOffsetSyntax

ISO G52: Local coordinate system offset (additive to G54-series).

G52 X10 Y20 Z5 → sets local offset. G52 X0 Y0 Z0 → cancels (resets to zero). M30 (program end) → also cancels.

Reads Parsing.G52 (from G52Syntax), writes LocalCoordinateOffset section, and adds a "LocalCoordinateOffset" entry to the transformation chain. Modal — persists via backward lookback until changed or cancelled.
LinearMotionSyntax

Writes McLinear motion for linear commands (ISO G00/G01, Heidenhain L/LN). Detects motion mode from Flags, writes IMotionDef section when MachineCoordinate exists.

McLinearMotionSemantic discriminates between XYZ-only and XYZABC motion by checking whether rotary axis values are present in MachineCoordinate.

Modal — persists across blocks via backward node lookback. Must be placed after McAbcSyntax in the syntax chain.
MachineCoordSelectSyntax

Handles G53 (machine coordinate selection) — non-modal, one-shot. The axis values (X/Y/Z) in the block are interpreted as machine coordinates, bypassing all work offsets, local coordinates, tool height compensation, and coordinate rotations. If G91 (incremental) is active, G53 is ignored per ISO standard.

Must be placed before ProgramXyzSyntax in the syntax chain. When G53 is active, this syntax consumes X/Y/Z from Parsing and writes MachineCoordinate directly, preventing ProgramXyzSyntax from processing them as program coordinates.

McAbcCyclicPathSyntax

Resolve modular rotary axes to the shortest cyclic path relative to the previous node. Uses IsModularRotary(string) to determine which axes within MachineCoordinate need cyclic resolution. Falls back to hardcoded A/B/C if no IMachineAxisConfig is available. Must be placed after ProgramXyzSyntax in NcSyntaxList.

McAbcSyntax

Writes rotary axis values (A/B/C) into MachineCoordinate from Parsing and modal lookback.

Only active when IMachineAxisConfig declares rotary axes. Works for both 3+2-axis (no IMachineKinematics) and simultaneous 5-axis configurations.

This syntax is intentionally ABC-only. When the block is rotary-only (no ProgramXyz, e.g. G00 A30.) the section is created with ABC but without X/Y/Z. McAbcXyzFallbackSyntax — placed after McXyzSyntax — copies X/Y/Z from the previous block's MachineCoordinate to finish the section. Splitting the XYZ fill out lets this syntax run before McXyzSyntax (and before G43p4RtcpSyntax) without accidentally filling X/Y/Z from prev and thereby short-circuiting DeriveMcXyz(JsonObject, Mat4d).

Missing rotary axes are filled from previous MachineCoordinate lookback, unless the current section already has the value (e.g., from HomeMcInitializer). Values are stored in degrees (matching McAbcCyclicPathSyntax).

Must be placed before McXyzSyntax so syntaxes that need the current-block ABC to compute transforms (e.g. G43p4RtcpSyntax) can see it; and before McAbcCyclicPathSyntax and LinearMotionSyntax.

McAbcXyzFallbackSyntax

Fills missing X/Y/Z on an ABC-only MachineCoordinate section. Behaviour depends on whether the block is under RTCP with rotary motion, as indicated by IsRotaryDynamic:

  • Non-dynamic (no RTCP or RTCP with ABC stable) — the programmed tool tip stays put in MC while rotary axes (if any) are unchanged, so we simply copy X/Y/Z from the previous block's MachineCoordinate. This matches NC modal XYZ carry-forward for rotary-only blocks such as G00 A30. (non-RTCP pivoting).
  • Dynamic (RTCP active + ABC changing) — the programmed tool tip must stay fixed in program coordinates while MC XYZ shifts to compensate the new rotary state. Looks up the last ProgramXyz and re-derives MC = inheritedProgramXyz × composedTransform, where the composed transform is the block's endpoint chain (now including PivotTransformSource as a full rotation+translation Mat4d, so the chain already encodes the kinematic IK). The carried ProgramXyz is also stamped onto the current block so downstream consumers see a consistent ProgramXyz + MC pair.

Pair with McAbcSyntax, which runs early to write ABC but deliberately leaves X/Y/Z empty so McXyzSyntax can still derive MC XYZ from ProgramXyz via the transform chain when the block carries linear motion. If McXyzSyntax has nothing to derive (no ProgramXyz), this syntax completes the MC section as described above.

Does nothing when the section already carries all three of X/Y/Z (normal linear-motion blocks), or when there is no section at all (pure parse-only block that introduces no MC). Must be placed after McXyzSyntax and before McAbcCyclicPathSyntax / LinearMotionSyntax.

McXyzSyntax

Derives MachineCoordinate from ProgramXyz by applying the composed EndPointProgramToMcTransform.

Processes two stages:

  1. Root ProgramXyz → root MachineCoordinate
  2. CompoundMotion.ItemsKey[*] — derives MachineCoordinate from ProgramXyz for items that have ProgramXyz but no MachineCoordinate
Must be placed after syntaxes that write ProgramXyz (e.g., ReferenceReturnSyntax) and before syntaxes that read MachineCoordinate (e.g., LinearMotionSyntax).
PathSmoothingSyntax

Consumes G05.1 (high-precision contour / path smoothing) and records its modal state. Q1 enables, Q0 disables. The simulation does not alter the tool path — this is a controller-internal interpolation black box.

PeckDrillingCycleSyntax

G83 peck drilling cycle. Supports modal repetition. Drills in increments of depth Q, fully retracting to R between strokes.

Cycle sequence (per stroke):

  1. Rapid to init position (target XY, previous Z)
  2. Rapid from init to R-point
  3. For each stroke: rapid to clearance above previous depth, feed Q deeper, rapid back to R
  4. If remainder exists: feed to bottom Z, rapid to R
  5. Rapid from R/bottom to final (G98 → init Z, G99 → R)

Retraction distance is read from ICannedCycleConfig (Fanuc #4002 / Syntec Pr4002, or FallbackConfig fallback).

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.

PivotTransformationSyntax

Writes the PivotTransformSource entry into EndPointProgramToMcTransform on every block, capturing the Pn→MC kinematic rigid transform for the block's endpoint rotary state. Mirrors legacy HardNcLine.GetProgramXyz's use of McToPn(DVec3d) — without this entry, the transform chain would miss the rotary rotation on any block whose MachineCoordinate.ABC is non-zero, and McXyzSyntax (and ProgramXyzSyntax's inverse lookback) would silently drift.

Scope is not limited to RTCP modal: as long as rotary axes are physically at a non-zero position (e.g. after a non-RTCP G00 B90 plus any subsequent motion), the kinematic chain still contributes a non-identity rigid transform that must appear in the endpoint chain. G43p4RtcpSyntax is orthogonal and only governs the IsRotaryDynamic flag used by LinearMotionSyntax to pick the motion form.

Chain position: must run after all Pn-frame writers (IsoG68p2TiltSyntax, ToolHeightOffsetSyntax, G43p4RtcpSyntax, IsoCoordinateOffsetSyntax, brand-specific coord offset syntaxes) so the PivotTransform entry is inserted as the last chain element (AddOrMoveToEndTransform(JsonObject, string, Mat4d)). Must run before McXyzSyntax / ProgramXyzSyntax so they see the completed chain.

Silently no-ops when IMachineKinematics is absent (3-axis configurations without rotary kinematics).

PlaneSelectSyntax

Consumes G17/G18/G19 plane selection from Flags and writes IPlaneSelectDef section using conventional axis-pair names (XY/ZX/YZ). Modal — persists via backward lookback. Default is XY (G17).

Downstream consumers (CircularMotionSyntax, IsoG68RotationSyntax) call GetPlaneNormalDir(JsonObject) to read the resolved plane.

PositioningModeSyntax

Detects G90/G91 positioning mode from Flags (or by modal lookback) and writes PositioningMode to the block JSON.

Fanuc/ISO: reads G90/G91 from Flags (global modal). Heidenhain: would need a separate implementation reading I-prefix per axis. Siemens: would extend with AC()/IC() per-axis override.

Does NOT convert incremental values — that is handled by IncrementalResolveSyntax which can be placed later in the syntax chain, after canned cycle syntaxes have consumed their parameters with cycle-specific G91 semantics.

ProgramEndSyntax

Consumes M02/M30 (program end) from Flags and writes IProgramEndDef section.

Downstream syntaxes that need to reset modal state on program end (e.g. IsoLocalCoordinateOffsetSyntax for G52 reset) should read the ProgramEnd section rather than scanning for M30 in Flags directly.

Must be placed before syntaxes that depend on the ProgramEnd section.
ProgramStopSyntax

Consumes M00 (unconditional stop) and M01 (optional stop) from Flags and writes a IProgramStopDef section on the block that carried the flag. Non-modal: the section is written only on the exact block where the stop code appears.

Siblings with ProgramEndSyntax (M02/M30) which handles end-of-program, not in-program stops.

The parsing layer only records NC intent. Whether M01 actually pauses the run is a runtime/semantic decision gated by the operator's "Optional Stop" switch (analogous to IBlockSkipConfig for block skip).

ProgramXyzSyntax

Resolves ProgramXyz (leaf coordinate) from syntax XYZ tags. Writes ProgramXyz sub-object to SyntaxPiece.JsonObject. Must be placed after BundleSyntax since it uses cross-node lookback for last position.

McXyzSyntax (placed after this in the chain) reads ProgramXyz and writes MachineCoordinate.

ProgramXyzUtil

Shared utilities for ProgramXyz and MachineCoordinate lookback and resolution. Used by ProgramXyzSyntax, ReferenceReturnSyntax, and semantic resolvers that need position lookback.

Two strategies for "what's the program coordinate at a block's endpoint?" — both invert an MC value through an EndPointProgramToMcTransform chain, but they pick the chain from different nodes:

  • By current-state transform (ComputeProgramXyzByCurrentTransform(LazyLinkedListNode<SyntaxPiece>, Vec3d)) — modal anchor is MachineCoordinate. Re-expresses an MC value (typically a predecessor's modal MC) into the current block's program frame using the current block's chain. Suitable for chain-change blocks where the spindle physically stays put while the chain (G54 swap, G68.2 activation, G43.4 toggle, tool-height change, ...) re-anchors the program frame; mirrors legacy HardNcLine.RebuildProgramXyzByMc.
  • By corresponding-state transform (ComputeProgramXyzByCorrespondingTransform(LazyLinkedListNode<SyntaxPiece>)) — modal anchor is ProgramXyz. Recovers the program coordinate that nodeCarryingMc was originally commanded at, by inverting that same node's own transform on its own MC. Suitable for RTCP rotary-dynamic inheritance, where the modal invariant is "tool tip in workpiece frame stays put while rotary axes turn" — the recovered Vec3d carries forward as the next rotary block's modal ProgramXyz unchanged, regardless of how its PivotTransform differs.

Both strategies yield the same Vec3d when prev and current share the same chain modal state; they only diverge across chain boundaries (RTCP toggle, coord-system swap, tilt activation) and at rotary motion (PivotTransform difference). Pick the wrong one and the result lands in a stale frame:

  • Non-RTCP using "corresponding" — leaves the pre-chain-change values, so a block emitted right after G43.4 H03 would inherit ProgramXyz still in the G49 frame and the next motion's MC.Z drifts by the introduced tool-height offset. (This was the 2026-04-25 SoftNc / HardNc divergence on DemoPmcAirPlane/NC/02-ED6L20.NC.)
  • RTCP using "current" — double-counts the rotary PivotTransform difference, so the inherited workpiece anchor rotates by the C delta on every rotary block.

Direct callers of the two strategy helpers are rare — typically you call the dispatcher ResolveBlockProgramXyz(LazyLinkedListNode<SyntaxPiece>, Vec3d) (block's own MC vs predecessor lookback, picks strategy from IsRotaryDynamic) or GetLastProgramXyz(LazyLinkedListNode<SyntaxPiece>) (pure predecessor lookback).

RadiusCompensationSyntax

Resolves cutter radius compensation (G41/G42/G40) by offsetting the tool path perpendicular to the programmed direction.

Must be placed after motion syntaxes (CircularMotionSyntax, LinearMotionSyntax) because it reads the Hi.Motion section. Must NOT be placed inside BundleSyntax because it requires look-forward (Next).

For simple cases (line-line, no transient), the syntax overwrites MachineCoordinate with the offset position. For arc blocks that need transient bridging segments, the Motion section is replaced with a CompoundMotion containing sub-items.

ReferenceReturnSyntax

Writes ICompoundMotionDef section for G28 reference point return. Reads intermediate XYZ from Parsing.G28 (written by G28Syntax) and converts to machine coordinates via ResolveProgramXyz(JsonNode, LazyLinkedListNode<SyntaxPiece>).

Must be placed after LinearMotionSyntax in the syntax chain. Removes the IMotionDef section written by LinearMotionSyntax (G28 handles its own motion). Overwrites root MachineCoordinate and ProgramXyz with reference position for subsequent block lookback.

RotaryAxisUtil

Shared utilities for rotary axis (A/B/C) resolution. Used by G53p1RotaryPositionSyntax, McAbcSyntax, IsoG68p2TiltSyntax, and other syntaxes that read or write rotary axis values.

SpindleSpeedSyntax

Consumes S (spindle speed) and M03/M04/M05 (spindle direction) from Parsing. Both are modal — persist across blocks via backward node lookback. Writes resolved state to a ISpindleSpeedDef section. Direction is converted from ISO M-codes to the conventional SpindleDirection enum at this layer.

TappingCycleSyntax

G84 (right-hand) / G74 (left-hand) tapping cycles. Supports modal repetition.

Cycle sequence:

  1. Rapid to init position (target XY, previous Z)
  2. Rapid from init to R-point
  3. Feed from R-point to bottom Z
  4. Spindle reverse at bottom
  5. Feed retract to final Z (G98 → init Z, G99 → R)
  6. Spindle restore to forward direction

G84: forward = CW (M03), reverse = CCW (M04). G74: forward = CCW (M04), reverse = CW (M03).

Reads absolute coordinates from the cycle section, which is resolved by CannedCycleResolveSyntax (modal repetition, G91 conversion, missing-axis fallback) before this syntax runs. Must be placed after CannedCycleResolveSyntax and before IncrementalResolveSyntax in the syntax chain.

TiltTransformUtil

Shared utilities for all tilt transform syntaxes (ISO, Siemens, Heidenhain). Handles section IO, backward lookback, and EndPointProgramToMcTransform composition.

ToolChangeSyntax

Consumes T (tool number) and M06 (tool change) from Parsing. T is modal — persists across blocks. M06 triggers the change. Writes resolved state to a ToolChange section: { “ToolId”: 1, “IsChange”: true }.

ToolHeightOffsetSyntax

Resolves ISO tool height offset (G43/G44/G49) to the effective offset value (mm) and composes the offset as a translation into the accumulated EndPointProgramToMcTransform matrix.

RTCP modes (G43.4, TRAORI, M128) are handled by separate brand-specific syntaxes (e.g., G43p4RtcpSyntax).

UnitModeSyntax

Detects the unit-system code (ISO Group 06: G20 inch / G21 metric) from Flags and writes a Unit section (Term, System). Modal — absence of an explicit flag inherits the previous block's unit, defaulting to Metric at program start.

The HiNC pipeline works exclusively in millimetres. When G20 is detected this syntax emits an Unit--InchNotSupported Unsupported Error so upstream callers are forced to pre-convert the NC program to metric. G21 is accepted as a no-op confirmation of the default.