Exemple #1
0
        void ReadSingleLineComment(Comment.Type commentType)
        {
            var st = new CodeLocation(Col, Line);
            string comm = ReadToEndOfLine().TrimStart('/');
            var end = new CodeLocation(Col, Line);

            if (commentType.HasFlag( Comment.Type.Documentation) || !OnlyEnlistDDocComments)
                Comments.Add(new Comment(commentType, comm.Trim(), st.Column < 2, st, end));
        }
Exemple #2
0
        void ReadMultiLineComment(Comment.Type commentType, bool isNestingComment)
        {
            int nestedCommentDepth = 1;
            int nextChar;
            CodeLocation st = new CodeLocation(Col, Line);
            StringBuilder scCurWord = new StringBuilder(); // current word, (scTag == null) or comment (when scTag != null)
            bool hadLineEnd = false;

            while ((nextChar = ReaderRead()) != -1)
            {

                char ch = (char)nextChar;

                // Catch deeper-nesting comments
                if (isNestingComment && ch == '/' && ReaderPeek() == '+')
                {
                    nestedCommentDepth++;
                    ReaderRead();
                }

                // End of multiline comment reached ?
                if ((isNestingComment ? ch == '+' : ch == '*') && ReaderPeek() == '/')
                {
                    ReaderRead(); // Skip "*" or "+"

                    if (nestedCommentDepth > 1)
                        nestedCommentDepth--;
                    else
                    {
                        if (commentType.HasFlag(Comment.Type.Documentation) || !OnlyEnlistDDocComments)
                            Comments.Add( new Comment(commentType, scCurWord.ToString().Trim(ch, ' ', '\t', '\r', '\n', isNestingComment ? '+' : '*'), st.Column < 2, st, new CodeLocation(Col, Line)));
                        return;
                    }
                }

                if (HandleLineEnd(ch))
                {
                    scCurWord.AppendLine();
                    hadLineEnd = true;
                }

                // Skip intial white spaces, leading + as well as *
                else if (hadLineEnd)
                {
                    if (char.IsWhiteSpace(ch) || (isNestingComment ? ch == '+' : ch == '*'))
                    { }
                    else
                    {
                        scCurWord.Append(ch);
                        hadLineEnd = false;
                    }
                }
                else
                    scCurWord.Append(ch);
            }

            // Reached EOF before end of multiline comment.
            if (commentType.HasFlag( Comment.Type.Documentation) || !OnlyEnlistDDocComments)
                Comments.Add(new Comment(commentType, scCurWord.ToString().Trim(), st.Column < 2, st, new CodeLocation(Col, Line)));

            OnError(Line, Col, String.Format("Reached EOF before the end of a multiline comment"));
        }
Exemple #3
0
		void ReadSingleLineComment(Comment.Type commentType)
		{
			int tagLen = ((commentType & Comment.Type.Documentation) != 0 ? 3 : 2);
			var st = new CodeLocation(Col - tagLen, Line);
			string comm = ReadToEndOfLine();
			var end = new CodeLocation(st.Column + tagLen + comm.Length, Line);

			if (reader.Peek () == -1 && st.Line == end.Line)
				endedWhileBeingInNonCodeSequence = true;

			if ((commentType &Comment.Type.Documentation) != 0 || !OnlyEnlistDDocComments)
				Comments.Add(new Comment(commentType, comm.TrimStart('/',' ','\t'), st.Column < 2, st, end));
		}
Exemple #4
0
        void ReadSingleLineComment(Comment.Type commentType)
        {
            int tagLen = ((commentType & Comment.Type.Documentation) != 0 ? 3 : 2);
            var st = new CodeLocation(Col - tagLen, Line);
            string comm = ReadToEndOfLine();
            var end = new CodeLocation(st.Column + tagLen + comm.Length, Line);

            if ((commentType &Comment.Type.Documentation) != 0 || !OnlyEnlistDDocComments)
                Comments.Add(new Comment(commentType, comm.TrimStart('/',' ','\t'), st.Column < 2, st, end));
        }
Exemple #5
0
 void ReadSingleLineComment(Comment.Type commentType)
 {
     var st = new CodeLocation(Col, Line);
     string comm = ReadToEndOfLine().TrimStart('/');
     var end = new CodeLocation(Col, Line);
     var nComm = new Comment(commentType, comm.Trim(), st.Column < 2, st, end);
     if (commentType == Comment.Type.Documentation)
         Comments.Add(nComm);
 }