public static bool TryTransformCommandLineLikeSyntax(Dsl.StatementData statementData, out Dsl.FunctionData result)
        {
            bool ret = false;

            result = null;
            if (null != statementData)
            {
                var first = statementData.First;
                if (first.HaveId() && !first.HaveParamOrStatement())
                {
                    //命令行样式转换为函数样式
                    var func = new Dsl.FunctionData();
                    func.CopyFrom(first);
                    func.SetParamClass((int)Dsl.FunctionData.ParamClassEnum.PARAM_CLASS_PARENTHESIS);
                    for (int i = 1; i < statementData.GetFunctionNum(); ++i)
                    {
                        var fd = statementData.GetFunction(i);
                        if (fd.HaveId() && !fd.HaveParamOrStatement())
                        {
                            func.AddParam(fd.Name);
                        }
                        else
                        {
                            func.AddParam(fd);
                        }
                    }
                    result = func;
                    ret    = true;
                }
            }
            return(ret);
        }
 public bool Init(Dsl.ISyntaxComponent config)
 {
     Dsl.StatementData statementData = config as Dsl.StatementData;
     if (null != statementData)
     {
         var first = statementData.First;
         if (first.HaveId() && !first.HaveParamOrStatement())
         {
             //命令行样式转换为函数样式
             var func = new Dsl.FunctionData();
             func.CopyFrom(first);
             func.SetParamClass((int)Dsl.FunctionData.ParamClassEnum.PARAM_CLASS_PARENTHESIS);
             for (int i = 1; i < statementData.GetFunctionNum(); ++i)
             {
                 var fd = statementData.GetFunction(i);
                 if (fd.HaveId() && !fd.HaveParamOrStatement())
                 {
                     func.AddParam(fd.Name);
                 }
                 else
                 {
                     func.AddParam(fd);
                 }
             }
             config = func;
         }
     }
     m_Comments = m_Params.InitFromDsl(config, 0, true);
     m_Config   = config;
     return(config is Dsl.FunctionData);
 }
예제 #3
0
 public static void SetStatementParam(Dsl.StatementData statementData, int funcIndex, int stIndex, int paramIndex, string val)
 {
     if (funcIndex >= 0 && funcIndex < statementData.GetFunctionNum())
     {
         Dsl.FunctionData funcData = statementData.GetFunction(funcIndex);
         SetStatementParam(funcData, stIndex, paramIndex, val);
     }
 }
예제 #4
0
 public bool Init(Dsl.ISyntaxComponent config)
 {
     m_LoadSuccess = true;
     m_Config      = config;
     Dsl.CallData callData = config as Dsl.CallData;
     if (null != callData)
     {
         Load(callData);
     }
     else
     {
         Dsl.FunctionData funcData = config as Dsl.FunctionData;
         if (null != funcData)
         {
             Load(funcData);
         }
         else
         {
             Dsl.StatementData statementData = config as Dsl.StatementData;
             if (null != statementData)
             {
                 int funcNum  = statementData.GetFunctionNum();
                 var lastFunc = statementData.Last;
                 var id       = lastFunc.GetId();
                 if (funcNum >= 2 && id == "comment" || id == "comments")
                 {
                     m_Comments = lastFunc;
                     statementData.Functions.RemoveAt(funcNum - 1);
                     if (statementData.GetFunctionNum() == 1)
                     {
                         funcData = statementData.GetFunction(0);
                         if (funcData.HaveStatement())
                         {
                             Load(funcData);
                         }
                         else
                         {
                             Load(funcData.Call);
                         }
                     }
                     else
                     {
                         Load(statementData);
                     }
                 }
                 else
                 {
                     Load(statementData);
                 }
             }
             else
             {
                 //keyword
             }
         }
     }
     return(m_LoadSuccess);
 }
예제 #5
0
        public bool Init(Dsl.ISyntaxComponent config)
        {
            bool ret = true;

            m_Config = config;
            m_Id     = config.GetId();
            Dsl.FunctionData funcData = config as Dsl.FunctionData;
            if (null != funcData)
            {
                Load(funcData);
            }
            else
            {
                Dsl.StatementData statementData = config as Dsl.StatementData;
                if (null != statementData)
                {
                    int funcNum  = statementData.GetFunctionNum();
                    var lastFunc = statementData.Last;
                    var id       = lastFunc.GetId();
                    if (funcNum >= 2 && (id == "comment" || id == "comments"))
                    {
                        m_Comments = lastFunc;
                        statementData.Functions.RemoveAt(funcNum - 1);
                        if (statementData.GetFunctionNum() == 1)
                        {
                            funcData = statementData.GetFunction(0);
                            ret      = Load(funcData);
                        }
                        else
                        {
                            ret = Load(statementData);
                        }
                    }
                    else
                    {
                        ret = Load(statementData);
                    }
                }
                else
                {
                    //keyword
                }
            }
            if (GameFramework.GlobalVariables.Instance.IsDevice)
            {
                //在设备上不保留配置信息了
                m_Comments = null;
                m_Config   = null;
            }
            return(ret);
        }
예제 #6
0
 static public int GetFunction(IntPtr l)
 {
     try {
         Dsl.StatementData self = (Dsl.StatementData)checkSelf(l);
         System.Int32      a1;
         checkType(l, 2, out a1);
         var ret = self.GetFunction(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #7
0
        private static bool CompareVariable(Dsl.StatementData data, Dsl.StatementData var)
        {
            bool ret = data.GetFunctionNum() == var.GetFunctionNum();

            if (ret)
            {
                int ct = data.GetFunctionNum();
                for (int i = 0; i < ct; ++i)
                {
                    var fl = data.GetFunction(i);
                    var fr = var.GetFunction(i);
                    ret = CompareVariable(fl, fr);
                    if (!ret)
                    {
                        break;
                    }
                }
            }
            return(ret);
        }
예제 #8
0
 public bool Init(Dsl.ISyntaxComponent config)
 {
     m_LoadSuccess = true;
     m_Config      = config;
     Dsl.FunctionData funcData = config as Dsl.FunctionData;
     if (null != funcData)
     {
         Load(funcData);
     }
     else
     {
         Dsl.StatementData statementData = config as Dsl.StatementData;
         if (null != statementData)
         {
             var first = statementData.First;
             if (first.HaveId() && !first.HaveParamOrStatement())
             {
                 //命令行样式转换为函数样式
                 var func = new Dsl.FunctionData();
                 func.CopyFrom(first);
                 func.SetParamClass((int)Dsl.FunctionData.ParamClassEnum.PARAM_CLASS_PARENTHESIS);
                 for (int i = 1; i < statementData.GetFunctionNum(); ++i)
                 {
                     var fd = statementData.GetFunction(i);
                     if (fd.HaveId() && !fd.HaveParamOrStatement())
                     {
                         func.AddParam(fd.Name);
                     }
                     else
                     {
                         func.AddParam(fd);
                     }
                 }
                 Load(func);
             }
             else
             {
                 int funcNum  = statementData.GetFunctionNum();
                 var lastFunc = statementData.Last;
                 var id       = lastFunc.GetId();
                 if (funcNum >= 2 && id == "comment" || id == "comments")
                 {
                     m_Comments = lastFunc;
                     statementData.Functions.RemoveAt(funcNum - 1);
                     if (statementData.GetFunctionNum() == 1)
                     {
                         funcData = statementData.GetFunction(0);
                         Load(funcData);
                     }
                     else
                     {
                         Load(statementData);
                     }
                 }
                 else
                 {
                     Load(statementData);
                 }
             }
         }
         else
         {
             //keyword
         }
     }
     return(m_LoadSuccess);
 }