Пример #1
0
            /// <summary>
            /// 清理
            /// </summary>
            private void ClearComment()
            {
                var  resII  = article.DetectNextN(2);
                var  resI   = article.DetectNextN(1);
                bool record = false;

                if (resII == "//")//1类注释 双斜杠
                {
                    article.Next();
                    article.Next();
                    record = false;;
                }
                else if (resI == "#")//2类注释 井号
                {
                    article.Next();
                    record = true;
                }
                else//若不是注释,直接返回
                {
                    return;
                }

                if (commentBuf == null)//如果注释记录是关闭的,record也关闭
                {
                    record = false;
                }

                StringBuilder curCmtRec = null;

                if (record)
                {
                    curCmtRec = new StringBuilder();
                }
                char?curCh = article.Cur();

                while (curCh.HasValue && curCh.Value != '\n')
                {
                    if (record && curCh.HasValue && curCh.Value != '\n')
                    {
                        curCmtRec.Append(curCh.Value);
                    }
                    article.Next();
                    curCh = article.Cur();
                }

                if (record)
                {
                    commentBuf.Add(curCmtRec.ToString());
                }
            }