/// <summary>
 /// Get the next interchange chunk to be processor.
 /// </summary>
 /// <param name="processor">Interchange format processor that contains the interchange sources.</param>
 /// <returns></returns>
 protected InterchangeChunk GetNextChunk(InterchangeFormatProcessor processor)
 {
     if (processor == null)
     {
         throw new ArgumentNullException();
     }
     return(processor.GetNextChunk());
 }
 /// <summary>
 /// Report that an error has occurred during parsing of the source code.
 /// </summary>
 /// <param name="processor">Interchange format processor whose error-sink is used to report the error.</param>
 /// <param name="parseErrorMessage">Error message.</param>
 protected void ReportError(InterchangeFormatProcessor processor, string parseErrorMessage)
 {
     if (processor == null)
     {
         throw new ArgumentNullException();
     }
     if (processor.ErrorSink != null)
     {
         processor.ErrorSink.AddInterchangeError(processor.SourcePosition, processor.SourcePosition, parseErrorMessage);
     }
 }
        /// <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));
        }
        /// <summary>
        /// Retrieve the next interchange chunk from the processor and parse it as an initializer.
        /// </summary>
        /// <param name="processor">Interchange format processor that can provide the interchange chunk for parsing.</param>
        /// <param name="sourceCodeService"></param>
        /// <remarks>
        /// The parser used here is capable of parsing interchange chunks containing initializers that follow the
        /// interchange version standard that this version service is supporting.
        /// </remarks>
        /// <returns>InitializerNode representing the parsed initializer source.</returns>
        protected internal virtual InitializerNode ParseInitializer(InterchangeFormatProcessor processor, out ISourceCodeReferenceService sourceCodeService)
        {
            InterchangeChunk chunk = this.GetNextChunk(processor);

            sourceCodeService = chunk;
            if (chunk == null)
            {
                // Must have an interchange element that contains <initializer definition>.
                this.ReportError(processor, "Expected initializer definition.");
                return(null);
            }
            Parser parser = this.GetFunctionParser();

            parser.ErrorSink = chunk;
            return(parser.ParseInitializer(new StringReader(chunk.SourceChunk)));
        }
        /// <summary>
        /// Process the interchange elements (chunks) provided by the given interchange format processor.
        /// </summary>
        /// <param name="processor">Interchange format processor that can provide interchange chunks for processing.</param>
        protected internal virtual void ProcessInterchangeElements(InterchangeFormatProcessor processor)
        {
            InterchangeChunk chunk = this.GetNextChunk(processor);

            if (chunk == null)
            {
                // Must have at least ONE interchange unit.
                this.ReportError(processor, InterchangeFormatErrors.ExpectedInterchangeUnit);
                return;
            }
            InterchangeUnitNode node = null;

            while (chunk != null)
            {
                node  = this.ProcessInterchangeElement(processor, node, chunk);
                chunk = this.GetNextChunk(processor);
            }
        }
Esempio n. 6
0
        public InterchangeInstallerContext Read(IEnumerable <FileInInformation> fileIns)
        {
            if (fileIns == null)
            {
                throw new ArgumentNullException("fileIns");
            }

            InterchangeInstallerContext installer = this.CreateInstallerContext();

            foreach (FileInInformation info in fileIns)
            {
                using (TextReader souceCodeReader = info.GetTextReader())
                {
                    InterchangeFormatProcessor processor = new InterchangeFormatProcessor(info, souceCodeReader, installer, this.VersionServicesMap);
                    processor.ProcessInterchangeFile();
                }
            }

            return(installer);
        }