Ejemplo n.º 1
0
        public static void ReturnObjectCheck(IFortranBlock block, string linesString, IEnumerable <IContained> subObjects, Action <IEnumerable <IFortranObject> > makeAssertions)
        {
            var lines  = StringUtils.ConvertToFileLineList(linesString);
            var actual = block.ReturnObject(subObjects, lines)
                         .ToList <IFortranObject>();

            makeAssertions(actual);
        }
Ejemplo n.º 2
0
            private bool EndBlock(
                int startIndex,
                int currentIndex,
                Stack <IFortranBlock> blockStack,
                IFortranBlock currentFactory,
                List <IContained> blockObjects,
                IEnumerable <IContained> blockSubObjects)
            {
                // End the block if we are at the end of the source.
                if (!this.ValidLineIndex(currentIndex, blockStack))
                {
                    return(true);
                }

                var blockSubObjectsList = blockSubObjects as List <IContained> ?? blockSubObjects.ToList();

                // If block has not ended yet then return.
                if (!currentFactory.BlockEnd(blockStack.Skip(1), _lines, currentIndex))
                {
                    return(false);
                }

                // At this point we assumn the block has ended and create the object represented by it.
                var blockLines = _lines.GetRange(startIndex, currentIndex - startIndex + 1);
                IEnumerable <IContained> parsingResult = null;

                try
                {
                    parsingResult = currentFactory.ReturnObject(blockSubObjectsList, blockLines);
                }
                catch (BlockParserException e)
                {
                    _errorListener.Error(new ParserException(blockLines.First().Number, blockLines.Last().Number, e.Message));
                }

                // If we have created a valid block then add it to the list and return.
                if (parsingResult != null)
                {
                    blockObjects.AddRange(parsingResult);
                }

                blockStack.Pop();
                return(true);
            }