/// <summary> /// Create and return a parser capable of parsing interchange nodes / interchange chunks. /// </summary> /// <remarks> /// The parser returned here is capable of parsing interchange chunks that follow the /// interchange version this version service is supporting. /// </remarks> /// <param name="sourceChunk">Interchange chunk to be parsed.</param> /// <returns>Interchange format parser.</returns> protected override InterchangeFormatParser GetInterchangeParser(InterchangeChunk sourceChunk) { if (sourceChunk == null) throw new ArgumentNullException(); InterchangeFormatParserIST10 parser = new InterchangeFormatParserIST10(new StringReader(sourceChunk.SourceChunk)); parser.ErrorSink = sourceChunk; return parser; }
/// <summary> /// Process a given interchange element (chunk). /// </summary> /// <param name="processor"></param> /// <param name="node">Last node that was parsed. This is used for annotations.</param> /// <param name="chunk">Interchange chunk to be processed.</param> /// <returns>Returns the new interchange parse node (or null in case of error).</returns> protected virtual InterchangeUnitNode ProcessInterchangeElement(InterchangeFormatProcessor processor, InterchangeUnitNode node, InterchangeChunk chunk) { InterchangeFormatParser parser = this.GetInterchangeParser(chunk); InterchangeElementNode nodeForAnnotation = (node == null) ? null : node.GetAnnotatedNode(); node = parser.ParseInterchangeElement(nodeForAnnotation); if (node == null) return null; return node.FileIn(processor, chunk, chunk); }