Пример #1
0
        /// <summary>
        /// 文字列の内容を行番号付きで出力します。
        /// </summary>
        /// <param name="data">文字列</param>
        public void DumpString(string data)
        {
            Rgx::MatchCollection mc = afh.Text.Regexs.Rx_NewLine.Matches(data);
            string f = "D" + System.Math.Max(mc.Count.ToString().Length, 4).ToString();

            this.Lock();
            int i = 0; int prev = 0;

            foreach (Rgx::Match m in mc)
            {
                this.AppendText(this.indent);
                this.AppendText(i++.ToString(f));
                this.AppendText("|");
                this.AppendText(data.Substring(prev, m.Index - prev));
                this.AppendText("\r\n");
                prev = m.Index + m.Length;
            }
            this.AppendText(this.indent);
            this.AppendText(i++.ToString(f));
            this.AppendText("|");
            this.AppendText(data.Substring(prev));
            this.AppendText("\r\n");

            this.Unlock();
        }
Пример #2
0
        private static void ResolveDefine(ref string text, ReportError report)
        {
            // 一つずつ #define を読込・適用
            Rgx::MatchCollection mc = rx_define_decl.Matches(text);

            for (int i = mc.Count - 1; i >= 0; i--)
            {
                new Define(mc[i]).Apply(ref text, report);
            }
        }
Пример #3
0
        public static void Resolve(ref string text, ReportError report)
        {
            Rgx::MatchCollection mc = rx_delete_s.Matches(text);

            for (int i = mc.Count - 1; i >= 0; i--)
            {
                Rgx::Match m_s = mc[i];
                Rgx::Match m_e = rx_delete_e.Match(text, m_s.Index);
                if (!m_e.Success)
                {
                    report("//#>>delete に対応する //#<<delete が存在しません。", m_s.Index);
                    continue;
                }

                // 削除
                int ss = m_s.Index;
                //int se=ss+m_s.Length;
                int es = m_e.Index;
                int ee = es + m_e.Length;
                text = text.Substring(0, ss) + text.Substring(ee);
            }
        }
Пример #4
0
        private static void ResolveTemplate(ref string text, ReportError report)
        {
            int i;

            // Entity に番号付け
            i = 0;
            Gen::Dictionary <string, int> indices = new Gen::Dictionary <string, int>();

            text = rx_entities_raw.Replace(text, delegate(Rgx::Match m){
                string key   = i++.ToString();
                int sharp    = m.Groups["sharp"].Index;
                indices[key] = sharp - 2;
                sharp       -= m.Index;
                return(m.Value.Substring(0, sharp) + "#" + key + m.Value.Substring(sharp));
            });

            // 一つずつ template を読込・適用
            Rgx::MatchCollection mc = rx_template_s.Matches(text);

            for (i = mc.Count - 1; i >= 0; i--)
            {
                ResolveTemplate(ref text, mc[i], report);
            }

            // #←template が残っていた場合
            foreach (Rgx::Match m in rx_template_e.Matches(text))
            {
                report("//#←template に対応する //#→template が存在しません。", m.Index);
            }

            // Entity が残っていた場合
            foreach (Rgx::Match m in rx_entities.Matches(text))
            {
                report("解決出来ない template 利用が存在します。", indices[m.Groups["num"].Value]);
            }
            // 方法
            // 1. ENTITY に数字を付け、元の位置との対応を記録
            // 2. ENTITY+数字 を検索し、数字部分から元の位置を取得
        }