示例#1
0
        private KeyValuePair <string, string> ParseHeredoc(Match match)
        {
            string fileName = match.Groups["FileName"].Value;

            (FoldLines fold, FinalFold final) = GetFoldType(match.Groups["Fold"].Value);

            if (!MoveNext())
            {
                return(new KeyValuePair <string, string>(fileName, string.Empty));
            }

            string indentation = Regex.Match(Current, @"^\s*").Value;

            if (indentation.Contains("\t"))
            {
                throw SpecFailure.FixtureParserIllegalTabs(_lex.Line);
            }

            StringBuilder sb = new StringBuilder();

            if (indentation.Length == 0)
            {
                // Encountered an empty here doc, treat as value
                _lex.MovePrevious();
                return(new KeyValuePair <string, string>(fileName, string.Empty));
            }

            string previous = null;

            foreach (var canonical in ReadHeredocLines(indentation))
            {
                fold(sb, canonical, previous);
                previous = canonical;
            }

            var body = final(sb);

            _lex.MovePrevious();
            return(new KeyValuePair <string, string>(fileName, body));
        }