Class ClsfRecordSyntax
- Namespace
- Hi.Numerical.ClsfParsers
- Assembly
- HiMech.dll
Per-record CLSF parsing syntax. Normalizes the block text (strips
$$ comments, joins $ continuation lines), splits it into the
record word and its comma-separated parameters, and stamps them into
JsonObject under ClsfRecordKey for
the downstream RecordTo* syntaxes to consume. Numeric parameters
are pre-typed to double.
The word is everything before the first / with whitespace runs
collapsed — multi-word heads (TOOL PATH) and hyphenated records
without parameters (END-OF-PATH) are single words, fixing the
legacy parser's first-token-only dispatch.
public class ClsfRecordSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
- Inheritance
-
ClsfRecordSyntax
- Implements
- Inherited Members
- Extension Methods
Examples
A GOTO record — word and typed parameters extracted, text fully consumed: #BeforeBuild:
{ "UnparsedText": "GOTO/10.5,20.25,3.5 $$ approach" }
#AfterBuild:
{ "ClsfRecord": { "Word": "GOTO", "Params": [10.5, 20.25, 3.5] } }
A multi-word head with a text parameter: #BeforeBuild:
{ "UnparsedText": "TOOL PATH/S1,TOOL,MILL_D10" }
#AfterBuild:
{ "ClsfRecord": { "Word": "TOOL PATH", "Params": ["S1", "TOOL", "MILL_D10"] } }
A record without parameters: #BeforeBuild:
{ "UnparsedText": "END-OF-PATH" }
#AfterBuild:
{ "ClsfRecord": { "Word": "END-OF-PATH", "Params": [] } }
Fields
ClsfRecordKey
JSON property name under which the parsed record is stored.
public const string ClsfRecordKey = "ClsfRecord"
Field Value
ParamsKey
Key of the parameter array inside the ClsfRecordKey section.
public const string ParamsKey = "Params"
Field Value
WordKey
Key of the record word inside the ClsfRecordKey section.
public const string WordKey = "Word"
Field Value
Properties
Name
Syntax kind name (typically the concrete type name).
public string Name { get; }
Property Value
XName
XML element name for Generators registration.
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.
Normalize(string)
Strips the $$ comment of every physical line, removes the
trailing $ continuation characters, and joins the lines into
one single-line record text.
public static string Normalize(string blockText)
Parameters
blockTextstringRaw (possibly multi-line) CLSF block text.
Returns
- string
The joined single-line record text; empty for comment-only blocks.
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
factoryXFactory