예제 #1
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);
 }
예제 #2
0
        public string   GetKOSCode()
        {
            string func = "//Properties\r\n";

            foreach (IKOSppObject p in KOSObjects.Where(x => x.GetType() == typeof(PropertyObject)))
            {
                func += p.GetKOSCode();
            }
            func += "//public functions\r\n";
            foreach (IKOSppObject f in KOSObjects.Where(x => x.IsPublic == true && x.Name != name && x.GetType() == typeof(FunctionObject)))
            {
                func += f.GetKOSCode();
            }
            func += "//private functions\r\n";
            foreach (IKOSppObject f in KOSObjects.Where(x => x.IsPublic == false && x.Name != name && x.GetType() == typeof(FunctionObject)))
            {
                func += f.GetKOSCode();
            }
            Phase2Compiler phase2 = new Phase2Compiler(ConstructorDefinition + func, KOSObjects);

            return(phase2.parse());
        }