Table of Contents

Class FanucIfThenParsingSyntax

Namespace
Hi.NcParsers.ParsingSyntaxs.Fanuc
Assembly
HiMech.dll

Parses the Fanuc Custom Macro B IF [<bool-expr>] THEN <body> single-block conditional phrase out of UnparsedText into a Parsing.FanucIfThen sub-object. Sibling to FanucGotoParsingSyntax — Fanuc spec only permits two IF-led control phrases (IF [...] GOTO <n> handled there, IF [...] THEN <stmt> handled here) so each form is matched phrase-level rather than composed from a generic IF combinator.

Body shape. The body after THEN is conceptually a single statement that affects the current block only — no jump, no label scan. Almost always a Custom Macro B assignment (#nnn = <expr>); multiple assignments in the same body (#100 = 5. #101 = #100 + 1) are also accepted. The parsing syntax pre-extracts these via GrabTagAssignment(ref string, IEnumerable<string>, string, IEnumerable<string>) into Parsing.FanucIfThen.PendingAssignments as {tag: rhs-string} entries — that shape lets VariableEvaluatorSyntax's pass-2 tree walk substitute each RHS to a numeric in place, and lets FanucIfThenSyntax lift the resolved entries into Parsing.Assignments only when the gate condition fires (so unfired bodies leave no trace in the readers).

Pipeline placement. This syntax must run before FanucGotoParsingSyntax — the bare IF-GOTO regex over there (^IF[..]GOTO n$) is anchored, but consuming IF-THEN here first keeps the two phrases textually disjoint and avoids any future regression if either regex is loosened. Also placed before TagAssignmentSyntax so a bare IF [...] THEN #100 = 5. is not first half-eaten as a plain assignment.

Raw BodyText is retained verbatim on the parsing section regardless of whether the body parsed as assignments — it carries the round-trip view and lets the evaluation syntax warn (FanucIfThen--UnsupportedBody) if no PendingAssignments were produced on a truthy condition.

public class FanucIfThenParsingSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
Inheritance
FanucIfThenParsingSyntax
Implements
Inherited Members
Extension Methods

Examples

#Input: IF [#1 GT 0] THEN #100 = #500 + 1 #Output:

{
  "Parsing": {
    "FanucIfThen": {
      "Condition": "#1 GT 0",
      "BodyText": "#100 = #500 + 1",
      "PendingAssignments": { "#100": "#500 + 1" }
    }
  }
}

Constructors

FanucIfThenParsingSyntax()

Parameterless instance for bundle composition (no XML state).

public FanucIfThenParsingSyntax()

FanucIfThenParsingSyntax(XElement)

XML ctor (no child elements; reserved for forward compatibility).

public FanucIfThenParsingSyntax(XElement src)

Parameters

src XElement

Root element named XName.

Properties

Name

Syntax kind name (typically the concrete type name).

public string Name { get; }

Property Value

string

XName

XML element name used to register this syntax with XFactory.

public static string XName { get; }

Property Value

string

Methods

Build(LazyLinkedListNode<SyntaxPiece>, List<INcDependency>, NcDiagnosticProgress)

Build syntax arrangement into the syntaxPieceNode in-place.

public void Build(LazyLinkedListNode<SyntaxPiece> syntaxPieceNode, List<INcDependency> ncDependencyList, NcDiagnosticProgress ncDiagnosticProgress)

Parameters

syntaxPieceNode LazyLinkedListNode<SyntaxPiece>
ncDependencyList List<INcDependency>
ncDiagnosticProgress NcDiagnosticProgress

MakeXmlSource(string, string, bool)

Creates an XML representation of the object. This method may also generate additional resources such as related files.

public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)

Parameters

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

exhibitionOnly bool

if true, the extended file creation is suppressed.

Returns

XElement

An XML element representing the object's state

Remarks

For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied. The baseDirectory is typically the folder at the nearest configuration file folder. Since the folder can be moving with the configuration file.

Reg(XFactory)

Registers this type's deserializer with the given XFactory (or Default when factory is null). Idempotent.

public static void Reg(XFactory factory = null)

Parameters

factory XFactory