Пример #1
0
        public static LexResult LexMultiLineComment(TextStream stream, bool init)
        {
            CppTokenKind kind = CppTokenKind.MultiLineComment;

            if (init)
            {
                Debug.Assert(stream.Peek(0) == '/');
                Debug.Assert(stream.Peek(1) == '*');
                stream.AdvanceColumns(2);
                char n = stream.Peek();
                if (DoxygenSyntax.MultiLineDocChars.Contains(n))
                {
                    stream.AdvanceColumn();
                    kind = CppTokenKind.MultiLineCommentDoc;
                    if (n == '*' && stream.Peek() == '/')
                    {
                        stream.AdvanceColumn();
                        return(new LexResult(kind, true));
                    }
                }
            }
            bool isComplete = false;

            while (!stream.IsEOF)
            {
                char c0 = stream.Peek();
                if (c0 == '*')
                {
                    char c1 = stream.Peek(1);
                    if (c1 == '/')
                    {
                        stream.AdvanceColumns(2);
                        isComplete = true;
                        break;
                    }
                    else
                    {
                        stream.AdvanceColumn();
                    }
                }
                else if (char.IsWhiteSpace(c0))
                {
                    stream.SkipAllWhitespaces();
                }
                else
                {
                    stream.AdvanceColumn();
                }
            }
            return(new LexResult(kind, isComplete));
        }