Beispiel #1
0
    /// <summary>
    /// 読み取った引数の内容を正規化します。(trim, dequotation)
    /// </summary>
    static string ReadArg(Rgx::Group g)
    {
        string ret = g.Value.Trim();

        if (ret.Length >= 2)
        {
            if (ret[0] == '"' || ret[0] == '\'')
            {
                ret = Rgx::Regex.Unescape(ret.Substring(1, ret.Length - 2));
            }
            else if (ret[0] == '/')
            {
                ret = ret.Substring(1, ret.Length - 2);
            }
        }
        return(ret);
    }
Beispiel #2
0
    public string GetProcessedAfter(Rgx::Match match)
    {
        string ret = this.after;

        ret = reg_after.Replace(ret, delegate(Rgx::Match m){
            //System.Console.WriteLine("replacement match: "+m.Value);
            if (m.Groups["num"].Success)
            {
                int n = int.Parse(m.Groups["num"].Value);
                if (n == 0)
                {
                    return(match.Value);
                }
                Rgx::Group g = match.Groups[n];
                if (g != null && g.Success)
                {
                    return(g.Value);
                }
            }
            else if (m.Groups["name"].Success)
            {
                Rgx::Group g = match.Groups[m.Groups["name"].Value];
                if (g != null && g.Success)
                {
                    return(g.Value);
                }
            }
            else
            {
                switch (m.Groups["cmd"].Value)
                {
                case "include":
                    string fname = m.Groups["arg"].Value.Trim();
                    fname        = System.IO.Path.Combine(this.directory, fname);
                    if (!System.IO.File.Exists(fname))
                    {
                        break;
                    }
                    return(System.IO.File.ReadAllText(fname));
                }
            }
            return(m.Value);
        });
        return(ret);
    }