Class LabelScanUtil
- Namespace
- Hi.NcParsers.EvaluationSyntaxs
- Assembly
- HiMech.dll
Shared “re-segment a file and skip pieces until a label matches”
scan, used by both
FanucGotoSyntax (unconditional GOTO redirect)
and SubProgramReturnSyntax (M99 P{seq} jump
into the caller file). Reads the file via
ReadLines(int, string, string), segments through the
provided ISegmenter, runs the
caller-supplied probe syntaxes on each candidate block to
extract IndexNote.Number, and returns the slice from the
first matching block to EOF.
Returns null 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).
public static class LabelScanUtil
- Inheritance
-
LabelScanUtil
- Inherited Members
Methods
SegmentAndSkipUntilLabel(ISegmenter, string, string, int, int, int, List<ISituNcSyntax>, NcDiagnosticProgress)
Re-segments absPath from offset 0, scans for
a block whose Number equals
targetN (after the
probeSyntaxes have stamped it in-place), and
returns the sub-list of pieces from that block to EOF.
Pieces are produced via
GetSyntaxPieces(ISegmenter, IEnumerable<IndexedFileLine>, int, NcDiagnosticProgress, CancellationToken) with
SentenceIndex stamped starting at
sentenceIndexBegin. Returns null when
no match is found; the caller emits its own brand-specific
“label not found” diagnostic.
The predicate is fixed at the
IndexNote.Number section
— the section name comes from nameof() so a future rename
propagates without re-edits. Reconfigurability for non-standard
label-output sections is achieved by replacing the probe syntaxes
(the natural extension point) rather than parameterising the
predicate path here: a probe stack that doesn't end up writing
IndexNote on candidates is by definition not
participating in this scan.
public static List<SyntaxPiece> SegmentAndSkipUntilLabel(ISegmenter segmenter, string absPath, string labelPath, int fileIndex, int sentenceIndexBegin, int targetN, List<ISituNcSyntax> probeSyntaxes, NcDiagnosticProgress diag)
Parameters
segmenterISegmenterSegmenter used to slice the file into Sentence blocks.
absPathstringAbsolute path to read line content from.
labelPathstringProject-relative path to stamp on each line's IndexedFileLine label (so diagnostics anchor to a relative form, not the resolver's transient absolute path).
fileIndexintFresh file index to stamp on each scanned line, allocated by the caller from FileIndexCounterDependency.
sentenceIndexBeginintStarting execution-order index for the produced pieces.
targetNintInteger label target to match against Number.
probeSyntaxesList<ISituNcSyntax>Ordered list of helper syntaxes to run on each candidate block before the predicate check (typically comment-stripper(s) followed by a head-index parser). May be null.
diagNcDiagnosticProgressSink for any diagnostics produced by the probe syntaxes (e.g. comment-stripper malformed-comment warnings).