Table of Contents

Class NamedVarAssignmentSyntax

Namespace
Hi.NcParsers.ParsingSyntaxs
Assembly
HiMech.dll

Assignment syntax for named (identifier-style) variables with = sign. Handles variables that are multi-character identifiers rather than {prefix}{digits}.

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

Examples

#BeforeBuild.UnparsedText: _X_HOME=500.0 #AfterBuild:

{
  "Parsing": { "Assignments": { "_X_HOME": "500.0" } }
}

#BeforeBuild.UnparsedText: _A=5 X=100 (the RHS stops at the next assignment-looking token; single-letter X= is not an identifier here and is left for the tag-value syntaxes) #AfterBuild:

{
  "UnparsedText": "X=100",
  "Parsing": { "Assignments": { "_A": "5" } }
}

Remarks

  • Siemens GUD: _X_HOME = 100, _MY_VAR = R1 + R2
  • Siemens LUD: DEF REAL MY_LOCAL; MY_LOCAL = 50
Unlike TagAssignmentSyntax which captures only the numbered {prefix}{digits} family (#1, R1, Q5), this identifier grammar is broader and also matches letter+digits tokens such as R1. The overlap is benign by construction: both assignment syntaxes route to the same Parsing.Assignments subtree with the same JSON shape, and a preset must give both the same TerminateWords; their RHS boundary rules are likewise aligned (any following token= stops the expression). A token captured by either therefore lands as the exact same JSON, so the relative ordering of the two syntaxes does not affect output. Identifiers must be at least 2 characters so single-letter axis addresses (X=100) stay with the tag-value syntaxes.

Constructors

NamedVarAssignmentSyntax(IEnumerable<string>, IEnumerable<string>, string)

Initializes a new instance with the given category path, optional terminator keywords, and an identifier regex pattern.

public NamedVarAssignmentSyntax(IEnumerable<string> categoryPath, IEnumerable<string> terminateWords = null, string identPattern = "[A-Za-z_]\\w+")

Parameters

categoryPath IEnumerable<string>

JSON path under Parsing where assignments are written. Pass null to use DefaultCategoryPath (Parsing.Assignments). Pass an empty collection only if assignments should land at the Parsing root.

terminateWords IEnumerable<string>

Optional keywords that end the right-hand expression.

identPattern string

Regex matching the variable identifier; defaults to DefaultIdentPattern.

NamedVarAssignmentSyntax(XElement)

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

public NamedVarAssignmentSyntax(XElement src)

Parameters

src XElement

Source XML element.

Fields

DefaultIdentPattern

Default identifier regex (at least 2 characters; first char letter or underscore). The 2-character minimum keeps single-letter axis addresses (X=100) with the tag-value syntaxes. Letter+digits tokens (R1) also match — that overlap with TagAssignmentSyntax is benign by construction (see the class remarks). Used when IdentPattern is not overridden.

public const string DefaultIdentPattern = "[A-Za-z_]\\w+"

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 — the same subtree as DefaultCategoryPath — so variable-reading syntaxes can target a single well-defined location.

public static IReadOnlyList<string> DefaultCategoryPath { get; }

Property Value

IReadOnlyList<string>

IdentPattern

Regex pattern for matching variable identifiers. Default: [A-Za-z_]\w+ (at least 2 characters).

public string IdentPattern { get; set; }

Property Value

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. Default None keeps the legacy lexical boundary. Must stay in sync with the value on RhsDialect in the same preset (the P0 behavior-alignment contract).

public NcExpressionDialect RhsDialect { get; set; }

Property Value

NcExpressionDialect

TerminateWords

Optional words (e.g. block-end keywords) that terminate the right-hand expression so the remainder is left in UnparsedText.

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

Property Value

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

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