Exemplo n.º 1
0
        //1756 Process.Load.csより移動
        public static void LoadEraExRenameFile(string filepath)
        {
            if (RenameDic != null)
                RenameDic.Clear();
            //とにかく辞書を作る。辞書がnullのときは UseRenameFileがNOの時のみ
            RenameDic = new Dictionary<string, string>();
            EraStreamReader eReader = new EraStreamReader();
            if ((!File.Exists(filepath)) || (!eReader.Open(filepath)))
            {
                return;
            }
            string line = null;
            ScriptPosition pos = null;
            Regex reg = new Regex(@"\\,", RegexOptions.Compiled);
            try
            {
                while ((line = eReader.ReadLine()) != null)
                {
                    if (line.Length == 0)
                        continue;
                    if (line.StartsWith(";"))
                        continue;
                    string[] baseTokens = reg.Split(line);
                    if (!baseTokens[baseTokens.Length - 1].Contains(","))
                        continue;
                    string[] last = baseTokens[baseTokens.Length - 1].Split(',');
                    baseTokens[baseTokens.Length - 1] = last[0];
                    string[] tokens = new string[2];
                    tokens[0] = string.Join(",", baseTokens);
                    tokens[1] = last[1];
                    pos = new ScriptPosition(eReader.Filename, eReader.LineNo, line);
                    //右がERB中の表記、左が変換先になる。
                    string value = tokens[0].Trim();
                    string key = string.Format("[[{0}]]", tokens[1].Trim());
                    RenameDic[key] = value;
                    pos = null;
                }
            }
            catch (Exception e)
            {
                if (pos != null)
                    throw new CodeEE(e.Message, pos);
                else
                    throw new CodeEE(e.Message);

            }
            finally
            {
                eReader.Close();
            }
        }
Exemplo n.º 2
0
 public static void LoadMacroFile(string filename)
 {
     EraStreamReader eReader = new EraStreamReader();
     if (!eReader.Open(filename))
         return;
     try
     {
         string line = null;
         while ((line = eReader.ReadLine()) != null)
         {
             if ((line.Length == 0) || (line[0] == ';'))
                 continue;
             for(int i = 0; i < MaxMacro;i++)
             {
                 if (line.StartsWith(macroName[i]))
                     macro[i] = line.Substring(macroName[i].Length);
             }
         }
     }
     catch { return; }
     finally { eReader.Dispose(); }
 }