예제 #1
0
        public IEnumerable<ISection> GetSections(ISource source)
        {
            var context = new Context
            {
                CurrentSource = source,
                CurrentState = State.WhiteSpace,
                CurrentPosition = SourcePosition.InitialPosition(),
                CurrentText = string.Empty
            };

            char? prev = null;
            ISection section = null;
            foreach (var c in source.GetChars())
            {
                if (!prev.HasValue)
                {
                    prev = c;
                    continue;
                }
                
                section = Analyze(prev, c, context);
                if (section != null)
                    yield return section;
                prev = c;
            }
            section = Analyze(prev, null, context);
            if (section != null)
                yield return section;
            section = EndOfFileActions(context);
            if (section != null)
                yield return section;
        }