Exemple #1
0
 /// <summary>
 /// メタデータを含むテキストデータを解析
 /// </summary>
 /// <param name="text">解析するテキスト</param>
 void Parse()
 {
     try
     {
         //テキストを先頭から1文字づつ解析
         int max = OriginalText.Length;
         currentTextIndex = 0;
         while (currentTextIndex < max)
         {
             if (ParseEscapeScance())
             {
                 //エスケープシーケンスの処理
             }
             else
             {
                 int endIndex = ParserUtil.ParseTag(OriginalText, currentTextIndex, ParseTagSub);
                 if (currentTextIndex == endIndex)
                 {
                     //通常パターンのテキストを1文字追加
                     AddChar(OriginalText[currentTextIndex]);
                     ++currentTextIndex;
                 }
                 else
                 {
                     currentTextIndex = endIndex + 1;
                 }
             }
         }
     }
     catch (System.Exception e)
     {
         AddErrorMsg(e.Message + e.StackTrace);
     }
 }
Exemple #2
0
 /// <summary>
 /// メタデータを含むテキストデータを解析
 /// </summary>
 /// <param name="text">解析するテキスト</param>
 protected virtual void Parse()
 {
     try
     {
         //テキストを先頭から1文字づつ解析
         int max   = OriginalText.Length;
         int index = 0;
         while (index < max)
         {
             if (ParseEscapeSequence(index))
             {
                 //エスケープシーケンスの処理
                 index += 2;
             }
             else
             {
                 string tagName  = "";
                 string tagArg   = "";
                 int    endIndex = ParserUtil.ParseTag(OriginalText, index,
                                                       (name, arg) =>
                 {
                     bool ret = ParseTag(name, arg);
                     if (ret)
                     {
                         tagName = name;
                         tagArg  = arg;
                     }
                     return(ret);
                 });
                 if (index == endIndex)
                 {
                     //タグがなかった
                     //通常パターンのテキストを1文字追加
                     AddChar(OriginalText[index]);
                     ++index;
                 }
                 else
                 {
                     //タグデータを挿入
                     string tagString = OriginalText.Substring(index, endIndex - index + 1);
                     PoolList.Insert(0, MakeTag(tagString, tagName, tagArg));
                     index = endIndex + 1;
                 }
             }
             ParsedDataList.AddRange(PoolList);
             PoolList.Clear();
         }
         PoolList.Clear();
     }
     catch (System.Exception e)
     {
         AddErrorMsg(e.Message + e.StackTrace);
     }
 }
Exemple #3
0
        /// <summary>
        /// メタデータを含むテキストデータを解析
        /// </summary>
        /// <param name="text">解析するテキスト</param>
        void Parse()
        {
            try
            {
                //テキストを先頭から1文字づつ解析
                int max = OriginalText.Length;
                currentTextIndex = 0;
                while (currentTextIndex < max)
                {
                    if (ParseEscapeSequence())
                    {
                        //エスケープシーケンスの処理
                    }
                    else
                    {
                        Func <string, string, bool> callbackParseTag;
                        if (isParseParamOnly)
                        {
                            callbackParseTag = ParseTagParamOnly;
                        }
                        else
                        {
                            callbackParseTag = ParseTag;
                        }

                        int endIndex = ParserUtil.ParseTag(OriginalText, currentTextIndex, callbackParseTag);
                        if (currentTextIndex == endIndex)
                        {
                            //通常パターンのテキストを1文字追加
                            AddChar(OriginalText[currentTextIndex]);
                            ++currentTextIndex;
                        }
                        else
                        {
                            currentTextIndex = endIndex + 1;
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                AddErrorMsg(e.Message + e.StackTrace);
            }
        }
 private void Parse()
 {
     try
     {
         int length = this.OriginalText.Length;
         this.currentTextIndex = 0;
         while (this.currentTextIndex < length)
         {
             if (!this.ParseEscapeSequence())
             {
                 Func <string, string, bool> func;
                 if (this.isParseParamOnly)
                 {
                     func = new Func <string, string, bool>(this.ParseTagParamOnly);
                 }
                 else
                 {
                     func = new Func <string, string, bool>(this.ParseTag);
                 }
                 int num2 = ParserUtil.ParseTag(this.OriginalText, this.currentTextIndex, func);
                 if (this.currentTextIndex == num2)
                 {
                     this.AddChar(this.OriginalText[this.currentTextIndex]);
                     this.currentTextIndex++;
                 }
                 else
                 {
                     this.currentTextIndex = num2 + 1;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.AddErrorMsg(exception.Message + exception.StackTrace);
     }
 }