Exemple #1
0
        public static IInstruction Load(string line)
        {
            DeclarationInstruction declarationInstruction = new DeclarationInstruction("", new object(), false, typeof(string));
            List <string>          list = new List <string>();

            Program.ToWords(line, 'ﻃ', (ICollection <string>)list);
            declarationInstruction.name     = list[1].Replace("\\n", "\n");
            declarationInstruction.setto    = (object)list[2].Replace("\\n", "\n");
            declarationInstruction.Variable = bool.Parse(list[3]);
            if (list.Count == 5)
            {
                if (Convert.ToString(list[4]) == "000001")
                {
                    declarationInstruction.orig_type = typeof(string);
                }
                else if (Convert.ToString(list[4]) == "000002")
                {
                    declarationInstruction.orig_type = typeof(int);
                }
                else
                {
                    if (!(Convert.ToString(list[4]) == "000003"))
                    {
                        throw new ArgumentException("type " + list[4] + " not supported.");
                    }
                    declarationInstruction.orig_type = typeof(bool);
                }
            }
            else
            {
                int result;
                declarationInstruction.orig_type = !int.TryParse(list[2].Replace("\\n", "\n"), out result) ? typeof(string) : typeof(int);
            }
            return((IInstruction)declarationInstruction);
        }
Exemple #2
0
 public static bool TryLoad(string line)
 {
     if (!(line.Substring(0, 7) == "declare"))
     {
         return(false);
     }
     DeclarationInstruction.Load(line);
     return(true);
 }