Beispiel #1
0
        public override void Init()
        {
            pFunEleme = new JFunEleme();
            pFunEleme.PVariableType = EVariableType.SetValue;
            pFunEleme.SetPoint(this.PBParser.Point);
            if (this.IsValidName)
            {
                this.GetTag();
                if (this._Tag == null && this.IsValidName)
                {
                    this.Error();
                }
                pFunEleme.PVariableType = EVariableType.Definition;
                this.pFunEleme.Name     = this._Tag;
                var exists = this.ValidateNameExists(this._Tag);
                if (exists != null)
                {
                    pFunEleme.PVariableType = EVariableType.SetValue;
                    this.pFunEleme.Name     = exists.GetAliasName();
                }
            }
            pFunEleme.Sign = (this.PBParser.VarIndexCount++).ToString();
            this.AddFather(pFunEleme);
            this.ValidChar('(');
            this.Args();
            this.SetArgs();
            this.ValidChar('{');
            this.AnalysisAnnotation(pFunEleme);
            var jsSpan = new JavaSciptSpan(this.PBParser, pFunEleme);

            jsSpan.Init();
            this.ValidChar('}');

            pFunEleme.AddEndPoint(this.PBParser.Point);
        }
        /// <summary>
        /// 函数
        /// </summary>
        /// <param name="fun"></param>
        /// <param name="desc"></param>
        private void ReadLAFun(JFunEleme fun, string desc)
        {
            string[] array  = desc.Trim().ToSplitStrings("\r\n");
            var      sbDesc = new StringBuilder();
            Regex    regex;
            Match    m;

            for (var i = 0; i < array.Length; i++)
            {
                array[i] = array[i].TrimStart('/', ' ', '\t');
                regex    = new Regex(@"^(\{([_a-zA-Z0-9]+)\})?\s*([_a-zA-Z0-9]+)");
                m        = regex.Match(array[i]);
                if (m != null && m.Success)
                {
                    if (fun.Variables == null)
                    {
                        continue;
                    }
                    var type  = m.Groups[2].Value;
                    var name  = m.Groups[3].Value;
                    var pdesc = array[i].Substring(m.Length).TrimStart();

                    BEleme pEleme;
                    if (fun.Variables.TryGetValue(name, out pEleme))
                    {
                        if ((pEleme as JDefinitionEleme).IsFunArg)
                        {
                            pEleme.Type = type;
                            pEleme.Desc = pdesc;
                        }
                    }
                }
                else if (i == array.Length - 1)
                {
                    regex = new Regex(@"^\{(\w+)\}");
                    m     = regex.Match(array[i]);
                    if (m != null)
                    {
                        fun.Type = m.Groups[1].Value;
                        continue;
                    }
                }
                else
                {
                    sbDesc.AppendLine(array[i]);
                }
            }

            fun.Desc = sbDesc.ToString();
        }