Пример #1
0
        public override string ToString()
        {
            string result = "{\"函数名\":\"" + functionname + "\",\n\"语句列表\":[";

            for (int i = 0; i < sentences.Count; i++)
            {
                Sentence s = sentences[i];
                if (s is IfElse)
                {
                    IfElse ifelse = s as IfElse;
                    result += ifelse.ToString() + (i == sentences.Count - 1 ? "" : ",");
                }
                else if (s is While)
                {
                    While @while = s as While;
                    result += @while.ToString() + (i == sentences.Count - 1 ? "" : ",");
                }
                else
                {
                    result += s.ToString() + (i == sentences.Count - 1 ? "" : ",");
                }
            }
            result += "],\n\"参数列表\":[";
            for (int i = 0; i < parametername.Count; i++)
            {
                result += "\"" + parametername[i].ToString() + "\"" + (i == parametername.Count - 1 ? "" : ",");
            }
            result += "],\n\"深度\":" + index + "}";
            return(result);
        }
Пример #2
0
        public override string ToString()
        {
            string result = "{\"判断语句\":" + judgesentence.ToString() + ",\n\"循环表达式\":";

            for (int i = 0; i < sentences.Count; i++)
            {
                result += sentences[i].ToString() + (i == sentences.Count - 1 ? "" : ",");
            }
            return(result.Substring(0, result.Length - 1) + "}");
        }
Пример #3
0
        public override string ToString()
        {
            string result = "{\"判断语句\":" + (judgesentence == null?"null":judgesentence.ToString()) + ",\n\"表达式\":";

            foreach (Sentence sen in sentences)
            {
                result += sen.ToString() + ",";
            }
            return(result.Substring(0, result.Length - 1) + "}");
        }