Table of Contents

Class TagAssignmentSyntax

Namespace
Hi.NcParsers.ParsingSyntaxs
Assembly
HiMech.dll

Assignment syntax with = sign. Unlike TagValueSyntax which handles concatenated tag-value pairs (no = sign), this class handles explicit assignment statements.

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

Examples

#BeforeBuild.UnparsedText: #100=5.0 (Fanuc, VarPrefix="#", TagList=[]) #AfterBuild:

{
  "Parsing": { "Assignments": { "#100": "5.0" } }
}

#BeforeBuild.UnparsedText: R1=100.5 (Siemens, VarPrefix=“R”, TagList=[]) #AfterBuild:

{
  "Parsing": { "Assignments": { "R1": "100.5" } }
}

#BeforeBuild.UnparsedText: R1=5 _A=6 (mixed line — R1's RHS stops at the next assignment-looking token; the named assignment is left for NamedVarAssignmentSyntax) #AfterBuild:

{
  "UnparsedText": "_A=6",
  "Parsing": { "Assignments": { "R1": "5" } }
}

Remarks

  • Fanuc: #1 = 100, #100 = [#1 + #2]
  • Siemens: R1 = 100, R1 = R2 + R3
  • Heidenhain: via derived HeidenhainFnAssignmentSyntax which adds FN prefix handling
Wraps GrabTagAssignment(ref string, IEnumerable<string>, string, IEnumerable<string>, ExpressionPrefixParser) as an INcSyntax.

Captures only the numbered {prefix}{digits} family; symbolic identifiers (e.g. _X_HOME) are the job of NamedVarAssignmentSyntax, whose broader identifier grammar also matches letter+digits tokens such as R1. That overlap is benign by construction: both route to the same Parsing.Assignments subtree with the same JSON shape (Assignments.<tag> = "<expr>"), share the same RHS boundary rule, and a preset must give both the same TerminateWords — so a token captured by either lands identically and the two syntaxes' relative order does not affect output. A controller with only numbered variables (Fanuc #) uses this syntax alone; NamedVarAssignmentSyntax cannot capture #-prefixed tokens.

Constructors

TagAssignmentSyntax(IEnumerable<string>, IEnumerable<string>, string, IEnumerable<string>)

Creates an assignment syntax. Pass null for categoryPath to use DefaultCategoryPath (Parsing.Assignments). Pass an empty collection only if assignments should land at the Parsing root.

public TagAssignmentSyntax(IEnumerable<string> categoryPath, IEnumerable<string> tags, string varPrefix, IEnumerable<string> terminateWords = null)

Parameters

categoryPath IEnumerable<string>
tags IEnumerable<string>
varPrefix string
terminateWords IEnumerable<string>

TagAssignmentSyntax(XElement)

Initializes a new instance by deserializing from the given XML element.

public TagAssignmentSyntax(XElement src)

Parameters

src XElement

Source XML element.

Fields

AssignmentsKey

Parsing sub-object key holding captured assignments — the shared landing spot of TagAssignmentSyntax, NamedVarAssignmentSyntax and SiemensDefStatementSyntax, and the read surface of the Evaluation-stage variable readers.

public const string AssignmentsKey = "Assignments"

Field Value

string

Properties

CategoryPath

JSON path under Parsing where matched assignments are written.

public List<string> CategoryPath { get; set; }

Property Value

List<string>

DefaultCategoryPath

Default CategoryPath assigned when the caller passes null (or omits the <CategoryPath> element in saved XML). Routes assignment outputs into Parsing.Assignments so that variable-reading syntaxes can target a single well-defined subtree.

public static IReadOnlyList<string> DefaultCategoryPath { get; }

Property Value

IReadOnlyList<string>

Name

Syntax kind name (typically the concrete type name).

public string Name { get; }

Property Value

string

RhsDialect

Expression grammar delimiting the RHS (parser-delimited capture): when set, the longest valid expression prefix ends the RHS — superseding TerminateWords on matches where a prefix parses — so spaced arithmetic and a following non-expression word split correctly. Default None keeps the legacy lexical boundary. Presets that set this on one assignment syntax must set it on NamedVarAssignmentSyntax too (the P0 behavior-alignment contract).

public NcExpressionDialect RhsDialect { get; set; }

Property Value

NcExpressionDialect

TagList

Numeric tag suffixes accepted (e.g. 1, 100) when paired with VarPrefix.

public List<string> TagList { get; set; }

Property Value

List<string>

TerminateWords

Optional keywords that terminate the right-hand expression so the remainder is left in UnparsedText.

public List<string> TerminateWords { get; set; }

Property Value

List<string>

VarPrefix

Variable prefix (e.g. #, R, Q) preceding the numeric tag.

public string VarPrefix { get; set; }

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 virtual 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

ToAssignmentJsonNode(string)

Converts an assignment expression string to a JsonNode. Override in derived classes for typed parsing.

protected virtual JsonNode ToAssignmentJsonNode(string setup)

Parameters

setup string

Returns

JsonNode

TryStripPrefix(ref string)

Strips a brand-specific prefix from unparsedText before assignment parsing. Returns false to signal no match (skip this syntax). Base implementation does nothing (no prefix required).

protected virtual bool TryStripPrefix(ref string unparsedText)

Parameters

unparsedText string

Returns

bool