Class ParameterizedFlagSyntax
- Namespace
- Hi.NcParsers.ParsingSyntaxs
- Assembly
- HiMech.dll
Syntax for flags with attached parameters (e.g., G54.1P1, G10L2P1). This is essentially a combination of main flag matching (like NumberedFlagSyntax) plus scoped TagValueSyntax for the parameters after the main flag. Note that the ParameterizedFlagSyntax often should be applied before NumberedFlagSyntax since NumberedFlagSyntax may eat the text that ParameterizedFlagSyntax should handle.
public class ParameterizedFlagSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
- Inheritance
-
ParameterizedFlagSyntax
- Implements
- Inherited Members
- Extension Methods
Remarks
Parameters can be stored as typed values via FloatParamPrefixes and IntParamPrefixes (set via property initializer):
- ParamPrefixes — stored as string (text, for variables like #1, Q2)
- FloatParamPrefixes — stored as double when parseable, string otherwise
- IntParamPrefixes — stored as int when parseable, string otherwise
- G54.1P1 → {"G54.1": {"P": "1"}} (text)
- G68.2 X0 I180 → {"G68.2": {"X": 0.0, "I": 180.0}} (float via property initializer)
- G54.1P#1 → {"G54.1": {"P": "#1"}} (Fanuc variable, kept as string)
- G54.1PQ1 → {"G54.1": {"P": "Q1"}} (Heidenhain variable)
Constructors
ParameterizedFlagSyntax(IEnumerable<string>, IEnumerable<string>, IEnumerable<string>, string, IEnumerable<string>)
Creates a new ParameterizedFlagSyntax instance. Use property initializers for FloatParamPrefixes and IntParamPrefixes to enable typed parameter storage.
public ParameterizedFlagSyntax(IEnumerable<string> categoryPath, IEnumerable<string> codePrefixes, IEnumerable<string> paramPrefixes, string varPrefix, IEnumerable<string> terminateWords = null)
Parameters
categoryPathIEnumerable<string>JSON path for storing matched codes.
codePrefixesIEnumerable<string>Full code prefixes to match (e.g., [“G54.1”, “G10”]).
paramPrefixesIEnumerable<string>Parameter prefixes to extract (e.g., [“P”, “L”]).
varPrefixstringVariable prefix (e.g., “#” for Fanuc, “Q” for Heidenhain).
terminateWordsIEnumerable<string>Words that stop parameter extraction.
ParameterizedFlagSyntax(XElement)
public ParameterizedFlagSyntax(XElement src)
Parameters
srcXElement
Properties
CategoryPath
Category path for storing matched codes in JSON.
public List<string> CategoryPath { get; set; }
Property Value
CodePrefixes
Full code prefixes to match (e.g., [“G54.1”, “G10”]).
public List<string> CodePrefixes { get; set; }
Property Value
FloatParamPrefixes
Parameter prefixes stored as double when parseable, string otherwise (for variable references). Set via property initializer for typed G-code parameters.
public List<string> FloatParamPrefixes { get; set; }
Property Value
IntParamPrefixes
Parameter prefixes stored as int when parseable, string otherwise (for variable references). Set via property initializer for typed G-code parameters.
public List<string> IntParamPrefixes { get; set; }
Property Value
Name
public string Name { get; }
Property Value
ParamPrefixes
Parameter prefixes to extract as text string (e.g., [“P”, “L”, “H”]). Multiple parameters can be attached to one code.
public List<string> ParamPrefixes { get; set; }
Property Value
TerminateWords
Words that terminate parameter extraction (e.g., [“G”, “M”, “X”, “Y”, “Z”]). Extraction stops when encountering these prefixes followed by a number.
public List<string> TerminateWords { get; set; }
Property Value
VarPrefix
Variable prefix for macro variables (e.g., “#” for Fanuc, “Q” for Heidenhain).
public string VarPrefix { get; set; }
Property Value
XName
public static string XName { get; }
Property Value
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
syntaxPieceNodeLazyLinkedListNode<SyntaxPiece>ncDependencyListList<INcDependency>ncDiagnosticProgressNcDiagnosticProgress
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
baseDirectorystringThe base directory for resolving relative paths
relFilestringThe relative file path for the XML source
exhibitionOnlyboolif 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.