如何扫描使用COFOJA编写的合同中使用的注释?

时间:2011-07-19 23:24:31

标签: java eclipse eclipse-plugin design-by-contract

我正在开发一个项目,我必须为使用COFOJA的方法编写合同,我必须使用启发式方法从合同中生成方法的代码。

1)我如何能够扫描COFOJA中使用的注释,如@ requires,@ensures等? 2)如果我生成抽象语法树,AST是否也包含注释/合同语言?

for ex:考虑关注我项目的输入

class Test{

@requires( { a> 0})
@ensures( {a==0 implies fact(a)=1 , and a>0 implies fact(a) = fact(a-1)*a } )

 public int fact (int a)
 {

  }

     }



       // Output of first version of code: (Its a rough estimate of code,)

     class Test1{

  public int fact (int a)
  {
    if (a==0)
   return 1;

     if(a >0)
      return a*fact(a-1);

      if(a<0) throw new AssertionException("Precondition failed/violated a<0 ");

           }

         } // end of class