如何扫描使用 COFOJA 编写的合同中使用的注释?
我正在开发一个项目,我必须使用 COFOJA 为方法编写合同,并且必须使用启发式方法从合同生成方法代码。
1) 我如何能够扫描 COFOJA 中使用的注释,如 @requires、@ensures 等? 2)如果我生成抽象语法树,AST是否也会包含注释/合约语言?
例如:考虑对我的项目进行以下输入
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
I am working on a project, where I have to write a contract for a method using COFOJA , and I have to generate code for method from the contracts using heuristics.
1) How will I be able to scan Annotations used in COFOJA like @ requires, @ensures etc?
2) IF I generate Abstract syntax tree, whether the AST will contain annotations / contract language also?
for ex: consider following input to my project
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置 Eclipse: http://webcourse .cs.technion.ac.il/236700/Spring2013/ho/WCFiles/Contracts%20for%20Java.pdf
对于科福亚:
https://fsteeg.wordpress。 com/2011/02/07/setting-up-contracts-for-java-in-eclipse/
to set eclipse: http://webcourse.cs.technion.ac.il/236700/Spring2013/ho/WCFiles/Contracts%20for%20Java.pdf
and for cofoja:
https://fsteeg.wordpress.com/2011/02/07/setting-up-contracts-for-java-in-eclipse/