Exemplo n.º 1
0
        public static string changeVariable(string word, List <IKOSppObject> ObjectList)
        {
            IKOSppObject KOSObject = ObjectList.SingleOrDefault(x => x.Name == word);

            if (KOSObject != null)
            {
                if (KOSObject.GetType() == typeof(VariableObject))
                {
                    return(KOSObject.CallString());
                }
                else if (KOSObject.GetType() == typeof(PropertyObject))
                {
                    return(KOSObject.CallString());
                }
            }
            return(word);
        }
Exemplo n.º 2
0
 public bool Parse(WordEngine oWordEngine)
 {
     done  = false;
     error = null;
     name  = "";
     value = "";
     isSet = false;
     if (oWordEngine.Current == "set")
     {
         name = oWordEngine.NextNonWhitespace;
         IKOSppObject nameObject = KOSObjects.SingleOrDefault(x => x.Name == name);
         if (nameObject != null && nameObject.GetType() == typeof(PropertyObject))
         {
             isSet = true;
         }
         else
         {
             name = Phase2Compiler.changeVariable(name, KOSObjects);
         }
         if (name != null)
         {
             if (oWordEngine.NextNonWhitespace == "to")
             {
                 while (oWordEngine.NextNonWhitespace != ".")
                 {
                     if (oWordEngine.Current == null)
                     {
                         error = "Expecting  ., found end of file insted.";
                         return(false);
                     }
                     else
                     {
                         value += Phase2Compiler.changeVariable(oWordEngine.Current, KOSObjects);
                     }
                 }
                 done = true;
                 if (isSet)
                 {
                     name = string.Format(nameObject.CallString(false), value);
                 }
                 return(true);
             }
             else
             {
                 error = "Expecting to, found " + oWordEngine.Current + " insted.";
             }
         }
         else
         {
             error = "Expecting to, end of file insted.";
         }
     }
     else
     {
         error = "Expecting set, found " + oWordEngine.Current + " insted.";
     }
     return(false);
 }