示例#1
0
        /// <summary>
        /// Extracts comments
        /// </summary>
        /// <param name="text">Text to perform extract on</param>
        /// <returns>List of comments</returns>
        public virtual IEnumerable <string> ExtractComments(string text)
        {
            MatchCollection matches = CommentsAndStringLiteralsRegexStringRegex.Matches(text);

            foreach (Match match in matches)
            {
                if (match.Groups[RegularExpressions.GroupInlineCommentName].Value != "")
                {
                    foreach (string commentWord in SplitOnWhiteSpaceRegex.Split(match.Groups[RegularExpressions.GroupInlineCommentName].Value))
                    {
                        if (commentWord != "")
                        {
                            yield return(commentWord);
                        }
                    }
                }

                if (match.Groups[RegularExpressions.GroupMultilineCommentName].Value != "")
                {
                    foreach (string commentWord in SplitOnWhiteSpaceRegex.Split(match.Groups[RegularExpressions.GroupMultilineCommentName].Value))
                    {
                        if (commentWord != "")
                        {
                            yield return(commentWord);
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Extracts string literals
        /// </summary>
        /// <param name="text">Text to perform extract on</param>
        /// <returns>List of string literals</returns>
        public virtual IEnumerable <string> ExtractStringLiterals(string text)
        {
            MatchCollection matches = CommentsAndStringLiteralsRegexStringRegex.Matches(text);

            foreach (string stringLiterals in (from Match match in matches
                                               where match.Groups[RegularExpressions.GroupStringLiteralsName].Value != ""
                                               select match.Groups[RegularExpressions.GroupStringLiteralsName].Value))
            {
                foreach (string stringLiteralWord in SplitOnWhiteSpaceRegex.Split(stringLiterals))
                {
                    if (stringLiteralWord != "")
                    {
                        yield return(stringLiteralWord);
                    }
                }
            }
        }