Ejemplo n.º 1
0
 public override void PrintFunction(ParseNode pn,int depth)
 {
     if (pn.IsUnnamed())
     {
         foreach (ParseNode child in pn)
             PrintFunction(child, depth);
     }
     else if (pn.RuleName == "pp_directive")
     {
         //PrintSimpleNode(pn);
     }
     else if (pn.RuleName == "comment_set")
     {
         //PrintSimpleNode(pn);
     }
     else if (pn.RuleName == "function_group")
     {
         if (pn.Count != 6)
         {
             Trace.Assert(false);
             return;
         }
         //string debug = pn[1].ToString();
         FunctionDefine func = new FunctionDefine();
         func.ReturnType = pn[2].ToString();
         func.FunctionName = pn[3].ToString();
         func.Param = pn[4].ToString();
         func.Body = pn[5].ToString();
         funList.Add(func);
     }
     else
     {
         if (pn.Count != 0)
         {
             foreach (ParseNode tmp in pn)
                 PrintFunction(tmp, depth + 1);
         }
     }
 }
Ejemplo n.º 2
0
        private void genrateFile(string fileName)
        {
            if (File.Exists(fileName))
            {
                MessageBox.Show("目标文件已经存在!","错误");
                return;
            }

            List<FunctionDefine> funList = new List<FunctionDefine>();;

            for (int i = 0; i < funcListBox.SelectedItems.Count; i++)
            {
                FunctionDefine funcItem = new FunctionDefine();
                funcItem.FunctionName = funcListBox.SelectedItems[i].ToString();
                funcItem.FunctionName = "test_" + funcItem.FunctionName;
                funList.Add(funcItem);
            }
            try
            {
                TestFile.genNewFile(fileName, funList);
            }catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }
            MessageBox.Show("生成成功!","成功");
        }