Table of Contents

Class SyntaxPiece

Namespace
Hi.NcParsers.Syntaxs
Assembly
HiMech.dll

One NC block's source line paired with its parsed JSON payload during soft-NC processing.

public class SyntaxPiece : ISentenceCarrier, IGetSentence, ISentenceIndexed
Inheritance
SyntaxPiece
Implements
Inherited Members
Extension Methods

Remarks

The design pattern of Sentence and JsonObject are one-one mapping.

JSON value type convention: Prefer base types (double, int) over string for numeric values in JsonObject. This applies to both parsing syntaxes and logic syntaxes. Strings should only be used when the value is genuinely textual (e.g., macro variable references like "#1", "Q2", coordinate IDs like "G54") or when the value cannot be parsed to a number. Use FloatTagValueSyntax, IntegerTagValueSyntax, or FloatParamPrefixes / IntParamPrefixes to store typed values at parse time.

Constructors

SyntaxPiece(Sentence, JsonObject, int)

Creates a piece binding sentence to jsonObject with its execution-order sentenceIndex.

public SyntaxPiece(Sentence sentence, JsonObject jsonObject, int sentenceIndex)

Parameters

sentence Sentence
jsonObject JsonObject
sentenceIndex int

Properties

JsonObject

Structured parse result built by syntax passes.

public JsonObject JsonObject { get; set; }

Property Value

JsonObject

Sentence

Indexed source line and block text for this piece.

public Sentence Sentence { get; set; }

Property Value

Sentence

SentenceIndex

0-based, session-globally unique ordinal in NC execution order. Stamped at piece construction time by GetSyntaxPieces(ISegmenter, List<INcDependency>, IEnumerable<IndexedFileLine>, int, NcDiagnosticProgress, CancellationToken) from the session's SentenceIndexCounterDependency: each piece allocates the next counter value as the lazy pipeline materializes it, so values are strictly increasing along the executed stream — subprogram / macro bodies inlined by SubProgramCallSyntax and friends interleave correctly between host blocks, including nested calls. Useful as a cross-process alignment key (messages, ClStripPos, MachiningStep) — unlike the (FileIndex, LineIndex) source order, it reflects execution order.

Values are NOT contiguous per file: eager label scans (LabelScanUtil / RewindToLine) number the whole re-segmented file and discard the pre-label prefix, leaving gaps. Never negative — -1 stays reserved as the "not in pipeline" sentinel on downstream carriers. When the counter dependency is absent (legacy XML preset), numbering falls back to the caller's contiguous begin-index sequence, which can double-book across inline boundaries.

Required at construction: the index is identity, not optional metadata. Read-only after construction; the pipeline guarantees one stamping per piece at the wrapping chokepoint.

public int SentenceIndex { get; }

Property Value

int

Methods

GetSentence()

Returns the source Sentence carried by this object.

public Sentence GetSentence()

Returns

Sentence

ToString()

Serialize with Hi.NcParsers.Syntaxs.NcSyntaxUtil.Options to support NaN/Infinity.

public override string ToString()

Returns

string