Beispiel #1
0
        public override IAst Parse(Token raw)
        {
            var re = new FnStmt();

            re.Name = raw.RawHeader.Trim().Split(' ')[1].Split('(')[0];

            if (raw.RawHeader.Split(')').Last().Contains(":"))
            {
                re.ReturnType = raw.RawHeader.Split(':').Last().Trim();
            }


            var s1 = Regex.Split(raw.RawHeader.Replace(" ", ""), re.Name + "\\(")[1];
            var s2 = "";

            if (!string.IsNullOrEmpty(re.ReturnType))
            {
                s2 = s1.Replace(":" + re.ReturnType, "").Trim().TrimEnd(')');
            }
            else
            {
                s2 = s1.Trim().TrimEnd(')');
            }

            if (s2 != "")
            {
                var prm = s2.Split(',');
                foreach (var i in prm)
                {
                    re.Parameters.Add(i.Split(':')[0], i.Split(':')[1]);
                }
            }



            foreach (var i in raw.Body)
            {
                re.Body.AddRange(IAst.ParseToken(i));
            }

            return(re);
        }
Beispiel #2
0
        public override IAst Parse(Token raw)
        {
            var re = new FnStmt();

            re.Name = raw.RawHeader.Trim().Split(' ')[1].Split('(')[0];

            if (raw.RawHeader.Split(')').Last().Contains(":"))
            {
                re.ReturnType = raw.RawHeader.Split(':').Last().Trim();
            }


            var s1 = Regex.Split(raw.RawHeader.Replace(" ", ""), re.Name + "\\(")[1];
            var s2 = "";
            if (!string.IsNullOrEmpty(re.ReturnType))
            {
                 s2 = s1.Replace(":" + re.ReturnType, "").Trim().TrimEnd(')');
            }
            else
            {
                s2 = s1.Trim().TrimEnd(')');
            }

            if (s2 != "")
            {
                var prm = s2.Split(',');
                foreach(var i in prm)
                {
                    re.Parameters.Add(i.Split(':')[0], i.Split(':')[1]);
                }
            }




            foreach (var i in raw.Body)
            {
                re.Body.AddRange(IAst.ParseToken(i));
            }

            return re;
        }